summaryrefslogtreecommitdiff
path: root/lib/slab.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/slab.c')
-rw-r--r--lib/slab.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/slab.c b/lib/slab.c
index c3035b45..f31355e0 100644
--- a/lib/slab.c
+++ b/lib/slab.c
@@ -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()