2 * Memory Pool prototypes
9 Copyright (C) 2000-2006 Kern Sibbald
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License
13 version 2 as amended with additional clauses defined in the
14 file LICENSE in the main source directory.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 the file LICENSE for additional details.
29 #define get_pool_memory(pool) sm_get_pool_memory(__FILE__, __LINE__, pool)
30 extern POOLMEM *sm_get_pool_memory(const char *file, int line, int pool);
32 #define get_memory(size) sm_get_memory(__FILE__, __LINE__, size)
33 extern POOLMEM *sm_get_memory(const char *fname, int line, int32_t size);
35 #define sizeof_pool_memory(buf) sm_sizeof_pool_memory(__FILE__, __LINE__, buf)
36 extern int32_t sm_sizeof_pool_memory(const char *fname, int line, POOLMEM *buf);
38 #define realloc_pool_memory(buf,size) sm_realloc_pool_memory(__FILE__, __LINE__, buf, size)
39 extern POOLMEM *sm_realloc_pool_memory(const char *fname, int line, POOLMEM *buf, int32_t size);
41 #define check_pool_memory_size(buf,size) sm_check_pool_memory_size(__FILE__, __LINE__, buf, size)
42 extern POOLMEM *sm_check_pool_memory_size(const char *fname, int line, POOLMEM *buf, int32_t size);
44 #define free_pool_memory(x) sm_free_pool_memory(__FILE__, __LINE__, x)
45 #define free_memory(x) sm_free_pool_memory(__FILE__, __LINE__, x)
46 extern void sm_free_pool_memory(const char *fname, int line, POOLMEM *buf);
51 extern POOLMEM *get_pool_memory(int pool);
52 extern POOLMEM *get_memory(int32_t size);
53 extern int32_t sizeof_pool_memory(POOLMEM *buf);
54 extern POOLMEM *realloc_pool_memory(POOLMEM *buf, int32_t size);
55 extern POOLMEM *check_pool_memory_size(POOLMEM *buf, int32_t size);
56 #define free_memory(x) free_pool_memory(x)
57 extern void free_pool_memory(POOLMEM *buf);
61 extern void garbage_collect_memory_pool();
62 extern void close_memory_pool();
63 extern void print_memory_pool_stats();
67 #define PM_NOPOOL 0 /* nonpooled memory */
68 #define PM_NAME 1 /* Bacula name */
69 #define PM_FNAME 2 /* file name buffer */
70 #define PM_MESSAGE 3 /* daemon message */
71 #define PM_EMSG 4 /* error message */
72 #define PM_MAX PM_EMSG /* Number of types */
77 POOL_MEM() { mem = get_pool_memory(PM_NAME); *mem = 0; }
78 POOL_MEM(int pool) { mem = get_pool_memory(pool); *mem = 0; }
79 ~POOL_MEM() { free_pool_memory(mem); mem = NULL; }
80 char *c_str() const { return mem; }
81 int size() const { return sizeof_pool_memory(mem); }
82 char *check_size(int32_t size) {
83 mem = check_pool_memory_size(mem, size);
87 void realloc_pm(int32_t size);
88 int strcpy(const char *str);
89 int strcat(const char *str);
92 int pm_strcat (POOLMEM **pm, const char *str);
93 int pm_strcat (POOLMEM *&pm, const char *str);
94 int pm_strcat (POOL_MEM &pm, const char *str);
95 int pm_strcat (POOLMEM *&pm, POOL_MEM &str);
96 int pm_strcpy (POOLMEM **pm, const char *str);
97 int pm_strcpy (POOLMEM *&pm, const char *str);
98 int pm_strcpy (POOL_MEM &pm, const char *str);
99 int pm_strcpy (POOLMEM *&pm, POOL_MEM &str);