| 1 | /************************************************* |
| 2 | * Exim - an Internet mail transport agent * |
| 3 | *************************************************/ |
| 4 | |
| 5 | /* Copyright (c) University of Cambridge 1995 - 2009 */ |
| 6 | /* See the file NOTICE for conditions of use and distribution. */ |
| 7 | |
| 8 | /* Header for Exim's memory allocation functions */ |
| 9 | |
| 10 | #ifndef STORE_H |
| 11 | #define STORE_H |
| 12 | |
| 13 | /* Define symbols for identifying the store pools. */ |
| 14 | |
| 15 | enum { POOL_MAIN, POOL_PERM, POOL_SEARCH, |
| 16 | POOL_TAINT_BASE, |
| 17 | POOL_TAINT_MAIN = POOL_TAINT_BASE, POOL_TAINT_PERM, POOL_TAINT_SEARCH }; |
| 18 | |
| 19 | /* This variable (the one for the current pool) is set by store_get() to its |
| 20 | yield, and by store_reset() to NULL. This allows string_cat() to optimize its |
| 21 | store handling. */ |
| 22 | |
| 23 | extern void *store_last_get[6]; |
| 24 | |
| 25 | /* This variable contains the current store pool number. */ |
| 26 | |
| 27 | extern int store_pool; |
| 28 | |
| 29 | /* Macros for calling the memory allocation routines with |
| 30 | tracing information for debugging. */ |
| 31 | |
| 32 | #define store_extend(addr, tainted, old, new) \ |
| 33 | store_extend_3(addr, tainted, old, new, __FUNCTION__, __LINE__) |
| 34 | |
| 35 | #define store_free(addr) \ |
| 36 | store_free_3(addr, __FUNCTION__, __LINE__) |
| 37 | #define store_get(size, tainted) \ |
| 38 | store_get_3(size, tainted, __FUNCTION__, __LINE__) |
| 39 | #define store_get_perm(size, tainted) \ |
| 40 | store_get_perm_3(size, tainted, __FUNCTION__, __LINE__) |
| 41 | #define store_malloc(size) \ |
| 42 | store_malloc_3(size, __FUNCTION__, __LINE__) |
| 43 | #define store_mark(void) \ |
| 44 | store_mark_3(__FUNCTION__, __LINE__) |
| 45 | #define store_newblock(addr, tainted, newsize, datalen) \ |
| 46 | store_newblock_3(addr, tainted, newsize, datalen, __FUNCTION__, __LINE__) |
| 47 | #define store_release_above(addr) \ |
| 48 | store_release_above_3(addr, __FUNCTION__, __LINE__) |
| 49 | #define store_reset(mark) \ |
| 50 | store_reset_3(mark, store_pool, __FUNCTION__, __LINE__) |
| 51 | |
| 52 | |
| 53 | /* The real functions */ |
| 54 | typedef void ** rmark; |
| 55 | |
| 56 | extern BOOL store_extend_3(void *, BOOL, int, int, const char *, int); |
| 57 | extern void store_free_3(void *, const char *, int); |
| 58 | extern void *store_get_3(int, BOOL, const char *, int) ALLOC ALLOC_SIZE(1) WARN_UNUSED_RESULT; |
| 59 | extern void *store_get_perm_3(int, BOOL, const char *, int) ALLOC ALLOC_SIZE(1) WARN_UNUSED_RESULT; |
| 60 | extern void *store_malloc_3(int, const char *, int) ALLOC ALLOC_SIZE(1) WARN_UNUSED_RESULT; |
| 61 | extern rmark store_mark_3(const char *, int); |
| 62 | extern void *store_newblock_3(void *, BOOL, int, int, const char *, int); |
| 63 | extern void store_release_above_3(void *, const char *, int); |
| 64 | extern rmark store_reset_3(rmark, int, const char *, int); |
| 65 | |
| 66 | #endif /* STORE_H */ |
| 67 | |
| 68 | /* End of store.h */ |