1 /*************************************************
2 * Exim - an Internet mail transport agent *
3 *************************************************/
5 /* Copyright (c) The Exim Maintainers 2020 - 2022 */
6 /* Copyright (c) University of Cambridge 1995 - 2009 */
7 /* See the file NOTICE for conditions of use and distribution. */
8 /* SPDX-License-Identifier: GPL-2.0-or-later */
10 /* Header for Exim's memory allocation functions */
15 /* Define symbols for identifying the store pools. */
25 POOL_TAINT_MAIN = POOL_TAINT_BASE,
34 /* This variable (the one for the current pool) is set by store_get() to its
35 yield, and by store_reset() to NULL. This allows string_cat() to optimize its
38 extern void * store_last_get[];
40 /* This variable contains the current store pool number. */
42 extern int store_pool;
44 /* Macros for calling the memory allocation routines with
45 tracing information for debugging. */
47 #define store_extend(addr, old, new) \
48 store_extend_3(addr, old, new, __FUNCTION__, __LINE__)
50 #define store_free(addr) \
51 store_free_3(addr, __FUNCTION__, __LINE__)
52 /* store_get & store_get_perm are in local_scan.h */
53 #define store_get_quoted(size, proto_mem, quoter, quoter_name) \
54 store_get_quoted_3((size), (proto_mem), (quoter), (quoter_name), \
55 __FUNCTION__, __LINE__)
56 #define store_malloc(size) \
57 store_malloc_3(size, __FUNCTION__, __LINE__)
58 #define store_mark(void) \
59 store_mark_3(__FUNCTION__, __LINE__)
60 #define store_newblock(oldblock, newsize, datalen) \
61 store_newblock_3(oldblock, newsize, datalen, __FUNCTION__, __LINE__)
62 #define store_release_above(addr) \
63 store_release_above_3(addr, __FUNCTION__, __LINE__)
64 #define store_reset(mark) \
65 store_reset_3(mark, __FUNCTION__, __LINE__)
68 /* The real functions */
69 typedef void ** rmark;
71 extern BOOL store_extend_3(void *, int, int, const char *, int);
72 extern void store_free_3(void *, const char *, int);
73 /* store_get_3 & store_get_perm_3 are in local_scan.h */
74 extern void * store_get_quoted_3(int, const void *, unsigned, const uschar *,
76 extern void * store_malloc_3(size_t, const char *, int) ALLOC ALLOC_SIZE(1) WARN_UNUSED_RESULT;
77 extern rmark store_mark_3(const char *, int);
78 extern void * store_newblock_3(void *, int, int, const char *, int);
79 extern void store_release_above_3(void *, const char *, int);
80 extern rmark store_reset_3(rmark, const char *, int);
82 #define GET_UNTAINTED (const void *)0
83 #define GET_TAINTED (const void *)1
85 extern int quoter_for_address(const void *, const uschar **);
86 extern BOOL is_quoted_like(const void *, unsigned);
87 extern BOOL is_real_quoter(int);
88 extern void debug_print_taint(const void * p);