-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvblibc_stack.h
More file actions
57 lines (47 loc) · 1.08 KB
/
Copy pathvblibc_stack.h
File metadata and controls
57 lines (47 loc) · 1.08 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef __VBLIBC_STACK_H
#define __VBLIBC_STACK_H
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* The Stack structure.
*/
typedef struct vb_stack_t {
/** Next item in the stack */
struct vb_stack_t *next;
/** Value of the item */
void *data;
} vb_stack_t;
/**
* Inserts an object at the top of the stack
*
* @param head The input head of the stack
* @param data The object to push onto the stack
*/
void vb_stack_push(vb_stack_t** head, void* data);
/**
* Removes and returns the object at the top of the stack
*
* @param head The input head of the stack
* @return void* The object at the top of the stack
*/
void* vb_stack_pop(vb_stack_t** head);
/**
* Destroys the stack
*
* @note Don't forget dispose (free) memory by points `vb_stack_t->data` if necessary.
* @param head The input head of the stack
*/
void vb_stack_destroy(vb_stack_t** head);
/**
* Get deep of the stack
*
* @param head The input head of the stack
* @return Deep of the stack
*/
int vb_stack_deep(vb_stack_t* head);
#ifdef __cplusplus
}
#endif
#endif /* !__VBLIBC_STACK_H */