Skip to content
Snippets Groups Projects
Commit bec8b7b6 authored by joey.martig's avatar joey.martig Committed by orestis.malaspin
Browse files

Resolve "Added destroy function" that frees the data and sets capacity and top to -1

parent 25c9c05a
Branches
Tags
1 merge request!18Resolve "Add destroy function"
......@@ -11,6 +11,13 @@ void stack_init(stack *s)
s->data = malloc(sizeof(int) * DEFAULT_CAPACITY);
}
void stack_destroy(stack *s){
free(s->data);
s->data = NULL;
s->capacity = -1;
s->top = -1;
}
void stack_peek(stack s, int *value){
if (!stack_is_empty(s)) {
*value = s.data[s.top];
......
......@@ -9,6 +9,8 @@ typedef struct _stack {
void stack_init(stack *stack);
void stack_destroy(stack *s);
void stack_peek(stack s, int *value);
void stack_clone(stack s, stack *clone);
int get_length(stack s);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment