about summary refs log tree commit diff
path: root/third_party/git/commit-slab-impl.h
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/git/commit-slab-impl.h')
-rw-r--r--third_party/git/commit-slab-impl.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/third_party/git/commit-slab-impl.h b/third_party/git/commit-slab-impl.h
index 5c0eb91a5d17..557738df271c 100644
--- a/third_party/git/commit-slab-impl.h
+++ b/third_party/git/commit-slab-impl.h
@@ -38,6 +38,19 @@ scope void clear_ ##slabname(struct slabname *s)			\
 	FREE_AND_NULL(s->slab);						\
 }									\
 									\
+scope void deep_clear_ ##slabname(struct slabname *s, void (*free_fn)(elemtype *)) \
+{									\
+	unsigned int i;							\
+	for (i = 0; i < s->slab_count; i++) {				\
+		unsigned int j;						\
+		if (!s->slab[i])					\
+			continue;					\
+		for (j = 0; j < s->slab_size; j++)			\
+			free_fn(&s->slab[i][j * s->stride]);		\
+	}								\
+	clear_ ##slabname(s);						\
+}									\
+									\
 scope elemtype *slabname## _at_peek(struct slabname *s,			\
 						  const struct commit *c, \
 						  int add_if_missing)   \