diff options
author | David Ward <david.ward@ll.mit.edu> | 2010-01-13 20:10:56 +0300 |
---|---|---|
committer | Denis Ovsienko <infrastation@yandex.ru> | 2010-01-13 20:10:56 +0300 |
commit | 0917f7e7c5920b70295c44bd8aad537bc3ee8581 (patch) | |
tree | d55fa58af8937c2373d532223cf9a7c35df95c64 | |
parent | b6516829595ed4fc47af955de8bda9ef5be14ffd (diff) |
lib: fix memory logging
* lib/memory.h
* mtype_zcalloc(): correct function prototype
* XFREE(): make both definitions consistent in setting
the pointer to NULL after freeing the memory
These changes will only have an effect if MEMORY_LOG is defined
(it is not by default).
-rw-r--r-- | lib/memory.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/memory.h b/lib/memory.h index 42eb5cae..a7eddce4 100644 --- a/lib/memory.h +++ b/lib/memory.h @@ -46,7 +46,10 @@ extern struct mlist mlists[]; #define XREALLOC(mtype, ptr, size) \ mtype_zrealloc (__FILE__, __LINE__, (mtype), (ptr), (size)) #define XFREE(mtype, ptr) \ - mtype_zfree (__FILE__, __LINE__, (mtype), (ptr)) + do { \ + mtype_zfree (__FILE__, __LINE__, (mtype), (ptr)); \ + ptr = NULL; } \ + while (0) #define XSTRDUP(mtype, str) \ mtype_zstrdup (__FILE__, __LINE__, (mtype), (str)) #else @@ -69,8 +72,7 @@ extern char *zstrdup (int type, const char *str); extern void *mtype_zmalloc (const char *file, int line, int type, size_t size); -extern void *mtype_zcalloc (const char *file, int line, int type, - size_t num, size_t size); +extern void *mtype_zcalloc (const char *file, int line, int type, size_t size); extern void *mtype_zrealloc (const char *file, int line, int type, void *ptr, size_t size); |