diff options
author | Mukund Sivaraman <muks@banu.com> | 2009-09-21 09:16:58 +0530 |
---|---|---|
committer | Mukund Sivaraman <muks@banu.com> | 2009-09-21 09:16:58 +0530 |
commit | 9d5a15ed2de783b0aea7ddaec3cc4d3804f291fd (patch) | |
tree | fb9796ab180b4278dd57306afb129dfe931c19cb /src | |
parent | d7ae6e4653f5b1f819ade300900deb248057eee3 (diff) | |
download | tinyproxy-9d5a15ed2de783b0aea7ddaec3cc4d3804f291fd.tar.gz tinyproxy-9d5a15ed2de783b0aea7ddaec3cc4d3804f291fd.zip |
[BB#18] Fix pointer aliasing issues
The changes were suggested by ians on the Banu forums.
Diffstat (limited to 'src')
-rw-r--r-- | src/heap.h | 15 |
1 files changed, 5 insertions, 10 deletions
@@ -40,21 +40,16 @@ extern char *debugging_strdup (const char *s, const char *file, # define safemalloc(x) debugging_malloc(x, __FILE__, __LINE__) # define saferealloc(x, y) debugging_realloc(x, y, __FILE__, __LINE__) # define safestrdup(x) debugging_strdup(x, __FILE__, __LINE__) -# define safefree(x) do { \ -void **__safefree_tmp = (void**)(&(x)); \ -debugging_free(*__safefree_tmp, __FILE__, __LINE__); \ -*__safefree_tmp = NULL; \ -} while (0) +# define safefree(x) (debugging_free(x, __FILE__, __LINE__), *(&(x)) = NULL) + #else + # define safecalloc(x, y) calloc(x, y) # define safemalloc(x) malloc(x) # define saferealloc(x, y) realloc(x, y) -# define safefree(x) do { \ -void **__safefree_tmp = (void**)(&(x)); \ -free(*__safefree_tmp); \ -*__safefree_tmp = NULL; \ -} while (0) +# define safefree(x) (free (x), *(&(x)) = NULL) # define safestrdup(x) strdup(x) + #endif /* |