about summary refs log tree commit diff
path: root/shared/systemd/src/basic/memory-util.h
diff options
context:
space:
mode:
authorSebastien Bacher <seb128@ubuntu.com>2020-05-19 16:38:51 +0200
committerSebastien Bacher <seb128@ubuntu.com>2020-05-19 16:38:51 +0200
commit96642ebde58e1eea692aea6a92d33f45452fa9c0 (patch)
tree106ddfa2180b3997e8965787b5cb122982ebab9d /shared/systemd/src/basic/memory-util.h
parent8f6881ac06714ef99cc470a03e7ac0ce1af49a16 (diff)
parentd460892bbfece74fb6d3cd846bf6ef548290be41 (diff)
Merge branch 'upstream/latest' of https://salsa.debian.org/utopia-team/network-manager into upstream/latestt pu
Diffstat (limited to 'shared/systemd/src/basic/memory-util.h')
-rw-r--r--shared/systemd/src/basic/memory-util.h20
1 files changed, 13 insertions, 7 deletions
diff --git a/shared/systemd/src/basic/memory-util.h b/shared/systemd/src/basic/memory-util.h
index 46a6907a..b7e2e67e 100644
--- a/shared/systemd/src/basic/memory-util.h
+++ b/shared/systemd/src/basic/memory-util.h
@@ -7,6 +7,7 @@
 #include <string.h>
 #include <sys/types.h>
 
+#include "alloc-util.h"
 #include "macro.h"
 
 size_t page_size(void) _pure_;
@@ -80,14 +81,19 @@ static inline void* explicit_bzero_safe(void *p, size_t l) {
 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;
 
-        if (ptr) {
-                size_t l = malloc_usable_size(ptr);
-                explicit_bzero_safe(ptr, l);
-                free(ptr);
-        }
+        l = malloc_usable_size(p);
+        explicit_bzero_safe(p, l);
+        return mfree(p);
+}
+
+static inline void erase_and_freep(void *p) {
+        erase_and_free(*(void**) p);
 }
 
 /* Use with _cleanup_ to erase a single 'char' when leaving scope */