]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mempool: make mempool_free_tile() return NULL
authorLennart Poettering <lennart@poettering.net>
Tue, 14 Feb 2023 12:42:03 +0000 (13:42 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 17 Feb 2023 14:03:10 +0000 (15:03 +0100)
To match how we usually do this current allocation code.

(Also, make it accept a NULL pointer, also in order to match behaviour
in the rest of our codebase)

src/basic/mempool.c
src/basic/mempool.h

index d934aa95475c8b9ef8ff0abaf96442ff531372ba..999b86d5cb725bf70128f9a11818c94fc1e01dd1 100644 (file)
@@ -70,9 +70,16 @@ void* mempool_alloc0_tile(struct mempool *mp) {
         return p;
 }
 
-void mempool_free_tile(struct mempool *mp, void *p) {
-        * (void**) p = mp->freelist;
+void* mempool_free_tile(struct mempool *mp, void *p) {
+        assert(mp);
+
+        if (!p)
+                return NULL;
+
+        *(void**) p = mp->freelist;
         mp->freelist = p;
+
+        return NULL;
 }
 
 void mempool_drop(struct mempool *mp) {
index 134e6cab1753dc6e019fb9247ff9422b6bd7c64c..6680ba3a9bab02806b9b5ab0a6a4ec5490133ca7 100644 (file)
@@ -15,7 +15,7 @@ struct mempool {
 
 void* mempool_alloc_tile(struct mempool *mp);
 void* mempool_alloc0_tile(struct mempool *mp);
-void mempool_free_tile(struct mempool *mp, void *p);
+void* mempool_free_tile(struct mempool *mp, void *p);
 
 #define DEFINE_MEMPOOL(pool_name, tile_type, alloc_at_least) \
 static struct mempool pool_name = { \