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) \
54 store_get_quoted_3((size), (proto_mem), (quoter), __FUNCTION__, __LINE__)
55 #define store_malloc(size) \
56 store_malloc_3(size, __FUNCTION__, __LINE__)
57 #define store_mark(void) \
58 store_mark_3(__FUNCTION__, __LINE__)
59 #define store_newblock(oldblock, newsize, datalen) \
60 store_newblock_3(oldblock, newsize, datalen, __FUNCTION__, __LINE__)
61 #define store_release_above(addr) \
62 store_release_above_3(addr, __FUNCTION__, __LINE__)
63 #define store_reset(mark) \
64 store_reset_3(mark, __FUNCTION__, __LINE__)
67 /* The real functions */
68 typedef void ** rmark;
70 extern BOOL store_extend_3(void *, int, int, const char *, int);
71 extern void store_free_3(void *, const char *, int);
72 /* store_get_3 & store_get_perm_3 are in local_scan.h */
73 extern void * store_get_quoted_3(int, const void *, unsigned, const char *, int);
74 extern void * store_malloc_3(size_t, const char *, int) ALLOC ALLOC_SIZE(1) WARN_UNUSED_RESULT;
75 extern rmark store_mark_3(const char *, int);
76 extern void * store_newblock_3(void *, int, int, const char *, int);
77 extern void store_release_above_3(void *, const char *, int);
78 extern rmark store_reset_3(rmark, const char *, int);
80 #define GET_UNTAINTED (const void *)0
81 #define GET_TAINTED (const void *)1
83 extern int quoter_for_address(const void *);
84 extern BOOL is_quoted_like(const void *, unsigned);
85 extern BOOL is_real_quoter(int);
86 extern void debug_print_taint(const void * p);