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