SPDX: license tags (mostly by guesswork)
[exim.git] / src / src / store.h
1 /*************************************************
2 *     Exim - an Internet mail transport agent    *
3 *************************************************/
4
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-only */
9
10 /* Header for Exim's memory allocation functions */
11
12 #ifndef STORE_H
13 #define STORE_H
14
15 /* Define symbols for identifying the store pools. */
16
17 enum { POOL_MAIN,
18        POOL_PERM,
19        POOL_CONFIG,
20        POOL_SEARCH,
21        POOL_MESSAGE,
22
23        POOL_TAINT_BASE,
24
25        POOL_TAINT_MAIN = POOL_TAINT_BASE,
26        POOL_TAINT_PERM,
27        POOL_TAINT_CONFIG,
28        POOL_TAINT_SEARCH,
29        POOL_TAINT_MESSAGE,
30
31        N_PAIRED_POOLS
32 };
33
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
36 store handling. */
37
38 extern void * store_last_get[];
39
40 /* This variable contains the current store pool number. */
41
42 extern int store_pool;
43
44 /* Macros for calling the memory allocation routines with
45 tracing information for debugging. */
46
47 #define store_extend(addr, old, new) \
48   store_extend_3(addr, old, new, __FUNCTION__, __LINE__)
49
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__)
65
66
67 /* The real functions */
68 typedef void ** rmark;
69
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);
79
80 #define GET_UNTAINTED   (const void *)0
81 #define GET_TAINTED     (const void *)1
82
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);
87
88 #endif  /* STORE_H */
89
90 /* End of store.h */