Add a function for initializing a struct commit_stack, for when static
initialization is not possible or impractical.
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
return run_hooks_opt(the_repository, name, &opt);
}
+void commit_stack_init(struct commit_stack *stack)
+{
+ stack->items = NULL;
+ stack->nr = stack->alloc = 0;
+}
+
void commit_stack_push(struct commit_stack *stack, struct commit *commit)
{
ALLOC_GROW(stack->items, stack->nr + 1, stack->alloc);
void commit_stack_clear(struct commit_stack *stack)
{
- FREE_AND_NULL(stack->items);
- stack->nr = stack->alloc = 0;
+ free(stack->items);
+ commit_stack_init(stack);
}
};
#define COMMIT_STACK_INIT { 0 }
+void commit_stack_init(struct commit_stack *);
void commit_stack_push(struct commit_stack *, struct commit *);
struct commit *commit_stack_pop(struct commit_stack *);
void commit_stack_clear(struct commit_stack *);