1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 19:21:53 +03:00

mempool: add a zeroing alloc function

Add mempool_alloc0_tile(). It's like mempool_alloc_tile(), but it
initializes the allocated tile's memory to zero.
This commit is contained in:
Michal Schmidt 2014-10-24 15:30:18 +02:00
parent b5de6d9842
commit 52fc5ce38c
2 changed files with 10 additions and 0 deletions

View File

@ -74,6 +74,15 @@ void* mempool_alloc_tile(struct mempool *mp) {
return ((uint8_t*) mp->first_pool) + ALIGN(sizeof(struct pool)) + i*mp->tile_size;
}
void* mempool_alloc0_tile(struct mempool *mp) {
void *p;
p = mempool_alloc_tile(mp);
if (p)
memzero(p, mp->tile_size);
return p;
}
void mempool_free_tile(struct mempool *mp, void *p) {
* (void**) p = mp->freelist;
mp->freelist = p;

View File

@ -34,6 +34,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);
#define DEFINE_MEMPOOL(pool_name, tile_type, alloc_at_least) \