void *explicit_bzero_safe(void *p, size_t l);
#endif
-static inline void erase_and_freep(void *p) {
- void *ptr = *(void**) p;
+static inline void* erase_and_free(void *p) {
+ size_t l;
+
+ if (!p)
+ return NULL;
+
+ l = malloc_usable_size(p);
+ explicit_bzero_safe(p, l);
+ free(p);
- if (ptr) {
- size_t l = malloc_usable_size(ptr);
- explicit_bzero_safe(ptr, l);
- free(ptr);
- }
+ return NULL;
+}
+
+static inline void erase_and_freep(void *p) {
+ erase_and_free(*(void**) p);
}
/* Use with _cleanup_ to erase a single 'char' when leaving scope */