-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.c
More file actions
31 lines (25 loc) · 696 Bytes
/
stack.c
File metadata and controls
31 lines (25 loc) · 696 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//
// Created by josoder on 08.09.17.
//
#include <stdlib.h>
#include "stack.h"
void stack_new_stack(stack *stack ,int elementSize, freeFunction freeFunction){
stack->list = malloc(sizeof(list));
list_new(stack->list, elementSize, freeFunction);
}
void stack_destroy_stack(stack *stack){
list_destroy(stack->list);
free(stack-> list);
}
void stack_push(stack *stack, void *element){
list_add_head(stack->list, element);
}
void stack_pop(stack *stack, void *element){
list_head(stack->list, element, true);
}
void stack_peek(stack *stack, void *element){
list_head(stack->list, element, false);
}
int stack_size(stack *stack){
return list_size(stack->list);
}