2 * Memory Pool prototypes
9 Bacula® - The Network Backup Solution
11 Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
13 The main author of Bacula is Kern Sibbald, with contributions from
14 many others, a complete list can be found in the file AUTHORS.
15 This program is Free Software; you can redistribute it and/or
16 modify it under the terms of version two of the GNU General Public
17 License as published by the Free Software Foundation plus additions
18 that are listed in the file LICENSE.
20 This program is distributed in the hope that it will be useful, but
21 WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
30 Bacula® is a registered trademark of John Walker.
31 The licensor of Bacula is the Free Software Foundation Europe
32 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
33 Switzerland, email:ftf@fsfeurope.org.
42 #define get_pool_memory(pool) sm_get_pool_memory(__FILE__, __LINE__, pool)
43 extern POOLMEM *sm_get_pool_memory(const char *file, int line, int pool);
45 #define get_memory(size) sm_get_memory(__FILE__, __LINE__, size)
46 extern POOLMEM *sm_get_memory(const char *fname, int line, int32_t size);
48 #define sizeof_pool_memory(buf) sm_sizeof_pool_memory(__FILE__, __LINE__, buf)
49 extern int32_t sm_sizeof_pool_memory(const char *fname, int line, POOLMEM *buf);
51 #define realloc_pool_memory(buf,size) sm_realloc_pool_memory(__FILE__, __LINE__, buf, size)
52 extern POOLMEM *sm_realloc_pool_memory(const char *fname, int line, POOLMEM *buf, int32_t size);
54 #define check_pool_memory_size(buf,size) sm_check_pool_memory_size(__FILE__, __LINE__, buf, size)
55 extern POOLMEM *sm_check_pool_memory_size(const char *fname, int line, POOLMEM *buf, int32_t size);
57 #define free_pool_memory(x) sm_free_pool_memory(__FILE__, __LINE__, x)
58 #define free_memory(x) sm_free_pool_memory(__FILE__, __LINE__, x)
59 extern void sm_free_pool_memory(const char *fname, int line, POOLMEM *buf);
64 extern POOLMEM *get_pool_memory(int pool);
65 extern POOLMEM *get_memory(int32_t size);
66 extern int32_t sizeof_pool_memory(POOLMEM *buf);
67 extern POOLMEM *realloc_pool_memory(POOLMEM *buf, int32_t size);
68 extern POOLMEM *check_pool_memory_size(POOLMEM *buf, int32_t size);
69 #define free_memory(x) free_pool_memory(x)
70 extern void free_pool_memory(POOLMEM *buf);
74 extern void garbage_collect_memory_pool();
75 extern void close_memory_pool();
76 extern void print_memory_pool_stats();
80 #define PM_NOPOOL 0 /* nonpooled memory */
81 #define PM_NAME 1 /* Bacula name */
82 #define PM_FNAME 2 /* file name buffer */
83 #define PM_MESSAGE 3 /* daemon message */
84 #define PM_EMSG 4 /* error message */
85 #define PM_MAX PM_EMSG /* Number of types */
90 POOL_MEM() { mem = get_pool_memory(PM_NAME); *mem = 0; }
91 POOL_MEM(int pool) { mem = get_pool_memory(pool); *mem = 0; }
92 ~POOL_MEM() { free_pool_memory(mem); mem = NULL; }
93 char *c_str() const { return mem; }
94 int size() const { return sizeof_pool_memory(mem); }
95 char *check_size(int32_t size) {
96 mem = check_pool_memory_size(mem, size);
100 void realloc_pm(int32_t size);
101 int strcpy(const char *str);
102 int strcat(const char *str);
105 int pm_strcat (POOLMEM **pm, const char *str);
106 int pm_strcat (POOLMEM *&pm, const char *str);
107 int pm_strcat (POOL_MEM &pm, const char *str);
108 int pm_strcat (POOLMEM *&pm, POOL_MEM &str);
109 int pm_strcpy (POOLMEM **pm, const char *str);
110 int pm_strcpy (POOLMEM *&pm, const char *str);
111 int pm_strcpy (POOL_MEM &pm, const char *str);
112 int pm_strcpy (POOLMEM *&pm, POOL_MEM &str);