From: Kern Sibbald Date: Sat, 14 May 2016 11:48:57 +0000 (+0200) Subject: Tweak smartalloc casting + prototypes X-Git-Tag: Release-7.4.1~10 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a064e788fefbaba1456be097b7b79472b2da3554;p=bacula%2Fbacula Tweak smartalloc casting + prototypes --- diff --git a/bacula/src/lib/mem_pool.c b/bacula/src/lib/mem_pool.c index fd748e71c7..a2e7606889 100644 --- a/bacula/src/lib/mem_pool.c +++ b/bacula/src/lib/mem_pool.c @@ -93,10 +93,10 @@ struct abufhead { static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; -#ifdef SMARTALLOC - #define HEAD_SIZE BALIGN(sizeof(struct abufhead)) +#ifdef SMARTALLOC + POOLMEM *sm_get_pool_memory(const char *fname, int lineno, int pool) { struct abufhead *buf; @@ -247,7 +247,7 @@ POOLMEM *get_pool_memory(int pool) return (POOLMEM *)((char *)buf+HEAD_SIZE); } - if ((buf=malloc(pool_ctl[pool].size+HEAD_SIZE)) == NULL) { + if ((buf=(struct abufhead*)malloc(pool_ctl[pool].size+HEAD_SIZE)) == NULL) { V(mutex); Emsg1(M_ABORT, 0, _("Out of memory requesting %d bytes\n"), pool_ctl[pool].size); } @@ -268,7 +268,7 @@ POOLMEM *get_memory(int32_t size) struct abufhead *buf; int pool = 0; - if ((buf=malloc(size+HEAD_SIZE)) == NULL) { + if ((buf=(struct abufhead *)malloc(size+HEAD_SIZE)) == NULL) { Emsg1(M_ABORT, 0, _("Out of memory requesting %d bytes\n"), size); } buf->ablen = size; diff --git a/bacula/src/lib/smartall.h b/bacula/src/lib/smartall.h index 787818326c..61ec9a95db 100644 --- a/bacula/src/lib/smartall.h +++ b/bacula/src/lib/smartall.h @@ -76,7 +76,7 @@ extern int sm_check_rtn(const char *fname, int lineno, bool bufdump); #define actuallymalloc(x) malloc(x) #define actuallycalloc(x,y) calloc(x,y) #define actuallyrealloc(x,y) realloc(x,y) -#define sm_dump(x) +inline void sm_dump(int x, int y=0) {} /* with default arguments, we can't use a #define */ #define sm_static(x) #define sm_new_owner(a, b, c) #define sm_malloc(f, l, n) malloc(n) @@ -84,9 +84,12 @@ extern int sm_check_rtn(const char *fname, int lineno, bool bufdump); #define sm_check(f, l, fl) #define sm_check_rtn(f, l, fl) 1 -extern void *b_malloc(); +extern void *b_malloc(const char *file, int line, size_t size); #define malloc(x) b_malloc(__FILE__, __LINE__, (x)) +#define Dsm_check(lvl) +#define sm_check(f, l, fl) +#define sm_check_rtn(f, l, fl) 1 #endif @@ -166,5 +169,4 @@ class SMARTALLOC } }; #endif /* SMARTALLOC */ - #endif /* !SMARTALLOC_H */