diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-09-29 22:59:17 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-09-29 22:59:17 +0000 |
commit | 5c53545d8158cd486d3ccef096f895afd485dd62 (patch) | |
tree | a1d83ddbcafe741af52750b9941af42e1ac01108 /src/common/util.c | |
parent | c6347cdb0ebb9ad0e374f345fbe085265caf0b15 (diff) | |
download | tor-5c53545d8158cd486d3ccef096f895afd485dd62.tar.gz tor-5c53545d8158cd486d3ccef096f895afd485dd62.zip |
Add a bunch more warnings to out warning suite; resolve them; pack structs a little better.
svn:r5150
Diffstat (limited to 'src/common/util.c')
-rw-r--r-- | src/common/util.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/common/util.c b/src/common/util.c index dd02661718..f2ddc27993 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -96,6 +96,7 @@ const char util_c_id[] = "$Id$"; * ===== */ #ifdef USE_DMALLOC #include <dmalloc.h> + #define DMALLOC_FN_ARGS file, line, #else #define dmalloc_strdup(file, line, string, xalloc_b) strdup(string) @@ -104,6 +105,7 @@ const char util_c_id[] = "$Id$"; #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 /** Allocate a chunk of <b>size</b> bytes of memory, and return a pointer to @@ -113,7 +115,8 @@ const char util_c_id[] = "$Id$"; * <b>file</b> and <b>line</b> are used if dmalloc is enabled, and * ignored otherwise. */ -void *_tor_malloc(const char *file, const int line, size_t size) { +void *_tor_malloc(DMALLOC_PARAMS size_t size) +{ void *result; /* Some libcs don't do the right thing on size==0. Override them. */ @@ -136,8 +139,8 @@ void *_tor_malloc(const char *file, const int line, size_t size) { * zero bytes, and return a pointer to the result. Log and terminate * the process on error. (Same as calloc(size,1), but never returns NULL.) */ -void *_tor_malloc_zero(const char *file, const int line, size_t size) { - void *result = _tor_malloc(file, line, size); +void *_tor_malloc_zero(DMALLOC_PARAMS size_t size) { + void *result = _tor_malloc(DMALLOC_FN_ARGS size); memset(result, 0, size); return result; } @@ -146,7 +149,7 @@ void *_tor_malloc_zero(const char *file, const int line, size_t size) { * bytes long; return the new memory block. On error, log and * terminate. (Like realloc(ptr,size), but never returns NULL.) */ -void *_tor_realloc(const char *file, const int line, void *ptr, size_t size) { +void *_tor_realloc(DMALLOC_PARAMS void *ptr, size_t size) { void *result; result = dmalloc_realloc(file, line, ptr, size, DMALLOC_FUNC_REALLOC, 0); @@ -161,7 +164,7 @@ void *_tor_realloc(const char *file, const int line, void *ptr, size_t size) { * error, log and terminate. (Like strdup(s), but never returns * NULL.) */ -char *_tor_strdup(const char *file, const int line, const char *s) { +char *_tor_strdup(DMALLOC_PARAMS const char *s) { char *dup; tor_assert(s); @@ -179,10 +182,10 @@ char *_tor_strdup(const char *file, const int line, const char *s) { * always NUL-terminated. (Like strndup(s,n), but never returns * NULL.) */ -char *_tor_strndup(const char *file, const int line, const char *s, size_t n) { +char *_tor_strndup(DMALLOC_PARAMS const char *s, size_t n) { char *dup; tor_assert(s); - dup = _tor_malloc(file, line, n+1); + dup = _tor_malloc(DMALLOC_FN_ARGS n+1); /* Performance note: Ordinarily we prefer strlcpy to strncpy. But * this function gets called a whole lot, and platform strncpy is * much faster than strlcpy when strlen(s) is much longer than n. |