From: Lennart Poettering Date: Tue, 14 Feb 2023 12:42:03 +0000 (+0100) Subject: mempool: make mempool_free_tile() return NULL X-Git-Tag: v254-rc1~1243^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4392b983b8e765a25c7bf081c06e8ecc37425274;p=thirdparty%2Fsystemd.git mempool: make mempool_free_tile() return NULL 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) --- diff --git a/src/basic/mempool.c b/src/basic/mempool.c index d934aa95475..999b86d5cb7 100644 --- a/src/basic/mempool.c +++ b/src/basic/mempool.c @@ -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) { diff --git a/src/basic/mempool.h b/src/basic/mempool.h index 134e6cab175..6680ba3a9ba 100644 --- a/src/basic/mempool.h +++ b/src/basic/mempool.h @@ -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 = { \