aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-02-15 20:13:53 -0500
committerNick Mathewson <nickm@torproject.org>2018-02-15 20:13:53 -0500
commit3e2b48f8b4eee456c4aa81f640185382642fa75c (patch)
tree719458a6af5ee29443c1fd44fa5fc539e6e892c6 /src
parentcfff582e4d68b4026d19c4cee4c2d893aaab116f (diff)
parent4dc228e35bbedb6f451a621db4a756ead9560a76 (diff)
downloadtor-3e2b48f8b4eee456c4aa81f640185382642fa75c.tar.gz
tor-3e2b48f8b4eee456c4aa81f640185382642fa75c.zip
Merge branch 'bug24484_squashed'
Diffstat (limited to 'src')
-rw-r--r--src/common/util.h18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/common/util.h b/src/common/util.h
index 2ee0ea28cd..653c154aba 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -73,9 +73,9 @@ extern int dmalloc_free(const char *file, const int line, void *pnt,
} \
STMT_END
#else /* !(defined(USE_DMALLOC)) */
-/** Release memory allocated by tor_malloc, tor_realloc, tor_strdup, etc.
- * Unlike the free() function, tor_free() will still work on NULL pointers,
- * and it sets the pointer value to NULL after freeing it.
+/** Release memory allocated by tor_malloc, tor_realloc, tor_strdup,
+ * etc. Unlike the free() function, the tor_free() macro sets the
+ * pointer value to NULL after freeing it.
*
* This is a macro. If you need a function pointer to release memory from
* tor_malloc(), use tor_free_().
@@ -88,17 +88,13 @@ extern int dmalloc_free(const char *file, const int line, void *pnt,
#ifdef __GNUC__
#define tor_free(p) STMT_BEGIN \
typeof(&(p)) tor_free__tmpvar = &(p); \
- if (PREDICT_LIKELY((*tor_free__tmpvar)!=NULL)) { \
- raw_free(*tor_free__tmpvar); \
- *tor_free__tmpvar=NULL; \
- } \
+ raw_free(*tor_free__tmpvar); \
+ *tor_free__tmpvar=NULL; \
STMT_END
#else
#define tor_free(p) STMT_BEGIN \
- if (PREDICT_LIKELY((p)!=NULL)) { \
- raw_free(p); \
- (p)=NULL; \
- } \
+ raw_free(p); \
+ (p)=NULL; \
STMT_END
#endif
#endif /* defined(USE_DMALLOC) */