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:
parent
b5de6d9842
commit
52fc5ce38c
@ -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;
|
||||
|
@ -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) \
|
||||
|
Loading…
Reference in New Issue
Block a user