]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/lib/mem_pool.h
839effc8ef8737e89dac91d1a0df99339bb9f828
[bacula/bacula] / bacula / src / lib / mem_pool.h
1 /*
2  * Memory Pool prototypes
3  *
4  *  Kern Sibbald, 2000
5  *
6  *   Version $Id$
7  */
8 /*
9    Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
10
11    This program is free software; you can redistribute it and/or
12    modify it under the terms of the GNU General Public License as
13    published by the Free Software Foundation; either version 2 of
14    the License, or (at your option) any later version.
15
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 GNU
19    General Public License for more details.
20
21    You should have received a copy of the GNU General Public
22    License along with this program; if not, write to the Free
23    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
24    MA 02111-1307, USA.
25
26  */
27
28 #ifndef __MEM_POOL_H_
29 #define __MEM_POOL_H_
30
31
32 #ifdef SMARTALLOC
33
34 #define get_pool_memory(pool) sm_get_pool_memory(__FILE__, __LINE__, pool)
35 extern POOLMEM *sm_get_pool_memory(const char *file, int line, int pool);
36
37 #define get_memory(size) sm_get_memory(__FILE__, __LINE__, size)
38 extern POOLMEM *sm_get_memory(const char *fname, int line, int32_t size);
39
40 #define sizeof_pool_memory(buf) sm_sizeof_pool_memory(__FILE__, __LINE__, buf)
41 extern int32_t sm_sizeof_pool_memory(const char *fname, int line, POOLMEM *buf);
42
43 #define realloc_pool_memory(buf,size) sm_realloc_pool_memory(__FILE__, __LINE__, buf, size)
44 extern POOLMEM  *sm_realloc_pool_memory(const char *fname, int line, POOLMEM *buf, int32_t size);
45
46 #define check_pool_memory_size(buf,size) sm_check_pool_memory_size(__FILE__, __LINE__, buf, size)
47 extern POOLMEM  *sm_check_pool_memory_size(const char *fname, int line, POOLMEM *buf, int32_t size);
48
49 #define free_pool_memory(x) sm_free_pool_memory(__FILE__, __LINE__, x) 
50 #define free_memory(x) sm_free_pool_memory(__FILE__, __LINE__, x) 
51 extern void sm_free_pool_memory(const char *fname, int line, POOLMEM *buf);
52
53
54 #else
55
56 extern POOLMEM *get_pool_memory(int pool);
57 extern POOLMEM *get_memory(int32_t size);
58 extern int32_t sizeof_pool_memory(POOLMEM *buf);
59 extern POOLMEM  *realloc_pool_memory(POOLMEM *buf, int32_t size);
60 extern POOLMEM  *check_pool_memory_size(POOLMEM *buf, int32_t size);
61 #define free_memory(x) free_pool_memory(x)
62 extern void   free_pool_memory(POOLMEM *buf);
63
64 #endif
65  
66 extern void  close_memory_pool();
67 extern void  print_memory_pool_stats();
68
69 #define PM_NOPOOL  0                  /* nonpooled memory */
70 #define PM_NAME    1                  /* Bacula name */
71 #define PM_FNAME   2                  /* file name buffer */
72 #define PM_MESSAGE 3                  /* daemon message */
73 #define PM_EMSG    4                  /* error message */
74 #define PM_MAX     PM_EMSG            /* Number of types */
75
76 #endif