From 26e7a05725bcb2cea59401803371ee3fa688a8f6 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 30 Sep 2005 01:39:24 +0000 Subject: even better function start checks; give dmalloc a chance of working. svn:r5162 --- src/common/util.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/common/util.h') diff --git a/src/common/util.h b/src/common/util.h index c4227b6d1..e644940b8 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -66,7 +66,18 @@ void *_tor_malloc_zero(DMALLOC_PARAMS size_t size); void *_tor_realloc(DMALLOC_PARAMS void *ptr, size_t size); char *_tor_strdup(DMALLOC_PARAMS const char *s); char *_tor_strndup(DMALLOC_PARAMS const char *s, size_t n); +#ifdef USE_DMALLOC +extern int dmalloc_free(const char *file, const int line, void *pnt, + const int func_id); +#define tor_free(p) do { \ + if (p) { \ + dmalloc_free(_SHORT_FILE_, __LINE__, (p), 0); \ + (p)=NULL; \ + } \ + } while (0) +#else #define tor_free(p) do { if (p) {free(p); (p)=NULL;} } while (0) +#endif #define tor_malloc(size) _tor_malloc(DMALLOC_ARGS size) #define tor_malloc_zero(size) _tor_malloc_zero(DMALLOC_ARGS size) -- cgit v1.2.3