alloc_wrappers: make free safe by not freeing null ptrs

This commit is contained in:
tylen 2024-09-25 09:35:36 +00:00 committed by Vasily Davydov
parent ec3de83413
commit 79ada91006

View File

@ -18,9 +18,10 @@
#define cdo_free(ptr) do { \ #define cdo_free(ptr) do { \
if (!ptr) { \ if (!ptr) { \
LOG_WARNING("Freeing NULL pointer."); \ LOG_WARNING("Trying to free NULL pointer. Skipping..."); \
} else { \
free(ptr); \
} \ } \
free(ptr); \
} while (0) } while (0)
#define cdo_calloc(nmemb, size) ((void*)({ \ #define cdo_calloc(nmemb, size) ((void*)({ \