diff options
author | Jacob Appelbaum <jacob@appelbaum.net> | 2008-10-26 22:56:53 +0000 |
---|---|---|
committer | Jacob Appelbaum <jacob@appelbaum.net> | 2008-10-26 22:56:53 +0000 |
commit | 7873d324df8b75f8d032b09c6fa5542e585f7ad9 (patch) | |
tree | e4961926da3d7b119f123568354aaa35ca62c00a | |
parent | b166a43cb6536574d96fc2c72d07b7eb908dfe99 (diff) | |
download | tor-7873d324df8b75f8d032b09c6fa5542e585f7ad9.tar.gz tor-7873d324df8b75f8d032b09c6fa5542e585f7ad9.zip |
This patch changes some of the code in util.c to refactor calls to
dmalloc_malloc, dmalloc_realloc and dmalloc_strdup. It only calls those
functions if we're using the magic USE_DMALLOC macro. If we're not doing
that, we call the normal malloc, realloc and strdup. This is my first
night at malloc disambiguation club, so I had to disambiguate. Also, first commit, I have my commit bit now. Huzzzah!!!
svn:r17157
-rw-r--r-- | src/common/util.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/common/util.c b/src/common/util.c index 701e1b8f94..093a3b1530 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -95,14 +95,8 @@ const char util_c_id[] = "$Id$"; #endif #else /* not using dmalloc */ - #define dmalloc_strdup(file, line, string, xalloc_b) strdup(string) - - #define dmalloc_malloc(file, line, size, func_id, alignment, xalloc_b) \ - malloc(size) #define DMALLOC_FUNC_MALLOC 0 - #define dmalloc_realloc(file, line, old_pnt, new_size, func_id, xalloc_b) \ - realloc((old_pnt), (new_size)) #define DMALLOC_FUNC_REALLOC 0 #define DMALLOC_FN_ARGS #endif @@ -125,7 +119,12 @@ _tor_malloc(size_t size DMALLOC_PARAMS) size=1; } #endif + +#ifdef USE_DMALLOC result = dmalloc_malloc(file, line, size, DMALLOC_FUNC_MALLOC, 0, 0); +#else + result = malloc(size); +#endif if (PREDICT_UNLIKELY(result == NULL)) { log_err(LD_MM,"Out of memory on malloc(). Dying."); @@ -158,7 +157,12 @@ _tor_realloc(void *ptr, size_t size DMALLOC_PARAMS) { void *result; +#ifdef USE_DMALLOC result = dmalloc_realloc(file, line, ptr, size, DMALLOC_FUNC_REALLOC, 0); +#else + result = realloc(ptr, size); +#endif + if (PREDICT_UNLIKELY(result == NULL)) { log_err(LD_MM,"Out of memory on realloc(). Dying."); exit(1); @@ -176,7 +180,11 @@ _tor_strdup(const char *s DMALLOC_PARAMS) char *dup; tor_assert(s); +#ifdef USE_DMALLOC dup = dmalloc_strdup(file, line, s, 0); +#else + dup = strdup(s); +#endif if (PREDICT_UNLIKELY(dup == NULL)) { log_err(LD_MM,"Out of memory on strdup(). Dying."); exit(1); |