aboutsummaryrefslogtreecommitdiff
path: root/src/common/util.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-09-30 01:39:24 +0000
committerNick Mathewson <nickm@torproject.org>2005-09-30 01:39:24 +0000
commit26e7a05725bcb2cea59401803371ee3fa688a8f6 (patch)
treeb81d9d8ee4672297b78012cecd17142616b2944e /src/common/util.h
parentedd15cb781934d91ae92adbe3311bf339ddbf2e8 (diff)
downloadtor-26e7a05725bcb2cea59401803371ee3fa688a8f6.tar
tor-26e7a05725bcb2cea59401803371ee3fa688a8f6.tar.gz
even better function start checks; give dmalloc a chance of working.
svn:r5162
Diffstat (limited to 'src/common/util.h')
-rw-r--r--src/common/util.h11
1 files changed, 11 insertions, 0 deletions
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)