3 Definitions for the smart memory allocator
8 Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2 of
13 the License, or (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public
21 License along with this program; if not, write to the Free
22 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
30 typedef enum {False = 0, True = 1} Boolean;
32 extern void *sm_malloc(char *fname, int lineno, unsigned int nbytes),
33 *sm_calloc(char *fname, int lineno,
34 unsigned int nelem, unsigned int elsize),
35 *sm_realloc(char *fname, int lineno, void *ptr, unsigned int size),
36 *actuallymalloc(unsigned int size),
37 *actuallycalloc(unsigned int nelem, unsigned int elsize),
38 *actuallyrealloc(void *ptr, unsigned int size);
39 extern void sm_free(char *fname, int lineno, void *fp);
40 extern void actuallyfree(void *cp),
41 sm_dump(Boolean bufdump), sm_static(int mode);
42 extern void sm_new_owner(char *fname, int lineno, char *buf);
45 extern void sm_check(char *fname, int lineno, Boolean bufdump);
46 extern int sm_check_rtn(char *fname, int lineno, Boolean bufdump);
48 #define sm_check(f, l, fl)
49 #define sm_check_rtn(f, l, fl) 1
53 /* Redefine standard memory allocator calls to use our routines
56 #define free(x) sm_free(__FILE__, __LINE__, (x))
57 #define cfree(x) sm_free(__FILE__, __LINE__, (x))
58 #define malloc(x) sm_malloc(__FILE__, __LINE__, (x))
59 #define calloc(n,e) sm_calloc(__FILE__, __LINE__, (n), (e))
60 #define realloc(p,x) sm_realloc(__FILE__, __LINE__, (p), (x))
64 /* If SMARTALLOC is disabled, define its special calls to default to
65 the standard routines. */
67 #define actuallyfree(x) free(x)
68 #define actuallymalloc(x) malloc(x)
69 #define actuallycalloc(x,y) calloc(x,y)
70 #define actuallyrealloc(x,y) realloc(x,y)
73 #define sm_new_owner(a, b, c)
74 #define sm_malloc(f, l, n) malloc(n)
76 #define sm_check(f, l, fl)
77 #define sm_check_rtn(f, l, fl) 1
79 extern void *b_malloc();
80 #define malloc(x) b_malloc(__FILE__, __LINE__, (x))