diff options
Diffstat (limited to 'lib/slab.c')
-rw-r--r-- | lib/slab.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -88,6 +88,14 @@ sl_alloc(slab *s) return o->data; } +void * +sl_allocz(slab *s) +{ + void *obj = sl_alloc(s); + memset(obj, 0, s->size); + return obj; +} + void sl_free(slab *s, void *oo) { @@ -279,6 +287,22 @@ no_partial: } /** + * sl_allocz - allocate an object from Slab and zero it + * @s: slab + * + * sl_allocz() allocates space for a single object from the + * Slab and returns a pointer to the object after zeroing out + * the object memory. + */ +void * +sl_allocz(slab *s) +{ + void *obj = sl_alloc(s); + memset(obj, 0, s->data_size); + return obj; +} + +/** * sl_free - return a free object back to a Slab * @s: slab * @oo: object returned by sl_alloc() |