summaryrefslogtreecommitdiffstats
path: root/src/basic/mempool.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-02-14 13:40:40 +0100
committerLennart Poettering <lennart@poettering.net>2023-02-17 15:02:18 +0100
commit72381db942dd00f4d69b2d9a50156a62f2c350da (patch)
tree1129ef3090dd249e44f17a51eed8c6a32faff9f4 /src/basic/mempool.c
parentmempool: rename local variable to match current coding style (diff)
downloadsystemd-72381db942dd00f4d69b2d9a50156a62f2c350da.tar.xz
systemd-72381db942dd00f4d69b2d9a50156a62f2c350da.zip
mempool: introduce new helper pool_ptr()
This new helper returns the beginning of the usable area of the pool object. For now this is only used once, a later commit will use it more.
Diffstat (limited to 'src/basic/mempool.c')
-rw-r--r--src/basic/mempool.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/basic/mempool.c b/src/basic/mempool.c
index 29f72a8171..d934aa9547 100644
--- a/src/basic/mempool.c
+++ b/src/basic/mempool.c
@@ -13,6 +13,10 @@ struct pool {
size_t n_used;
};
+static void* pool_ptr(struct pool *p) {
+ return ((uint8_t*) ASSERT_PTR(p)) + ALIGN(sizeof(struct pool));
+}
+
void* mempool_alloc_tile(struct mempool *mp) {
size_t i;
@@ -54,7 +58,7 @@ void* mempool_alloc_tile(struct mempool *mp) {
i = mp->first_pool->n_used++;
- return ((uint8_t*) mp->first_pool) + ALIGN(sizeof(struct pool)) + i*mp->tile_size;
+ return (uint8_t*) pool_ptr(mp->first_pool) + i*mp->tile_size;
}
void* mempool_alloc0_tile(struct mempool *mp) {