[BB#18] Fix pointer aliasing issues

The changes were suggested by ians on the Banu forums.
This commit is contained in:
Mukund Sivaraman 2009-09-21 09:16:58 +05:30
parent d7ae6e4653
commit 9d5a15ed2d

View File

@ -40,21 +40,16 @@ extern char *debugging_strdup (const char *s, const char *file,
# define safemalloc(x) debugging_malloc(x, __FILE__, __LINE__) # define safemalloc(x) debugging_malloc(x, __FILE__, __LINE__)
# define saferealloc(x, y) debugging_realloc(x, y, __FILE__, __LINE__) # define saferealloc(x, y) debugging_realloc(x, y, __FILE__, __LINE__)
# define safestrdup(x) debugging_strdup(x, __FILE__, __LINE__) # define safestrdup(x) debugging_strdup(x, __FILE__, __LINE__)
# define safefree(x) do { \ # define safefree(x) (debugging_free(x, __FILE__, __LINE__), *(&(x)) = NULL)
void **__safefree_tmp = (void**)(&(x)); \
debugging_free(*__safefree_tmp, __FILE__, __LINE__); \
*__safefree_tmp = NULL; \
} while (0)
#else #else
# define safecalloc(x, y) calloc(x, y) # define safecalloc(x, y) calloc(x, y)
# define safemalloc(x) malloc(x) # define safemalloc(x) malloc(x)
# define saferealloc(x, y) realloc(x, y) # define saferealloc(x, y) realloc(x, y)
# define safefree(x) do { \ # define safefree(x) (free (x), *(&(x)) = NULL)
void **__safefree_tmp = (void**)(&(x)); \
free(*__safefree_tmp); \
*__safefree_tmp = NULL; \
} while (0)
# define safestrdup(x) strdup(x) # define safestrdup(x) strdup(x)
#endif #endif
/* /*