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. */
9 /* Header for Exim's memory allocation functions */
14 /* Define symbols for identifying the store pools. */
24 POOL_TAINT_MAIN = POOL_TAINT_BASE,
33 /* This variable (the one for the current pool) is set by store_get() to its
34 yield, and by store_reset() to NULL. This allows string_cat() to optimize its
37 extern void * store_last_get[];
39 /* This variable contains the current store pool number. */
41 extern int store_pool;
43 /* Macros for calling the memory allocation routines with
44 tracing information for debugging. */
46 #define store_extend(addr, old, new) \
47 store_extend_3(addr, old, new, __FUNCTION__, __LINE__)
49 #define store_free(addr) \
50 store_free_3(addr, __FUNCTION__, __LINE__)
51 /* store_get & store_get_perm are in local_scan.h */
52 #define store_get_quoted(size, proto_mem, quoter) \
53 store_get_quoted_3((size), (proto_mem), (quoter), __FUNCTION__, __LINE__)
54 #define store_malloc(size) \
55 store_malloc_3(size, __FUNCTION__, __LINE__)
56 #define store_mark(void) \
57 store_mark_3(__FUNCTION__, __LINE__)
58 #define store_newblock(oldblock, newsize, datalen) \
59 store_newblock_3(oldblock, newsize, datalen, __FUNCTION__, __LINE__)
60 #define store_release_above(addr) \
61 store_release_above_3(addr, __FUNCTION__, __LINE__)
62 #define store_reset(mark) \
63 store_reset_3(mark, __FUNCTION__, __LINE__)
66 /* The real functions */
67 typedef void ** rmark;
69 extern BOOL store_extend_3(void *, int, int, const char *, int);
70 extern void store_free_3(void *, const char *, int);
71 /* store_get_3 & store_get_perm_3 are in local_scan.h */
72 extern void * store_get_quoted_3(int, const void *, unsigned, const char *, int);
73 extern void * store_malloc_3(size_t, const char *, int) ALLOC ALLOC_SIZE(1) WARN_UNUSED_RESULT;
74 extern rmark store_mark_3(const char *, int);
75 extern void * store_newblock_3(void *, int, int, const char *, int);
76 extern void store_release_above_3(void *, const char *, int);
77 extern rmark store_reset_3(rmark, const char *, int);
79 #define GET_UNTAINTED (const void *)0
80 #define GET_TAINTED (const void *)1
82 extern int quoter_for_address(const void *);
83 extern BOOL is_quoted_like(const void *, unsigned);
84 extern BOOL is_real_quoter(int);
85 extern void debug_print_taint(const void * p);