-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.h
More file actions
35 lines (25 loc) · 688 Bytes
/
stack.h
File metadata and controls
35 lines (25 loc) · 688 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
32
33
34
35
#ifndef STACK_H
#define STACK_H
#include <stdlib.h>
typedef struct stack_elem {
void *value;
struct stack_elem *next;
} stack_elem_t;
typedef struct {
stack_elem_t *top;
} stack_t;
stack_t *stack_create(void);
void stack_push(stack_t *stack, void *val);
void *stack_pop(stack_t *stack);
void *stack_peek(stack_t *stack);
/*
* Free all elements on the stack and the stack itself.
* This doesn't free the references on the stack;
*/
void stack_destroy(stack_t *stack);
/*
* Free all elements on the stack, the items refered to on the stack
* and the stack itself.
*/
void stack_destroy_with_elements(stack_t *stack);
#endif