forked from ainfosec/MoRE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stack.h
78 lines (58 loc) · 1.7 KB
/
stack.h
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
@file
Header file to provide a FIFO stack data structure
@date 1/25/2012
***************************************************************/
#include "stdint.h"
/** Maximum number of elements in the stack at a time */
#define MAX_STACK_SIZE 100
/** Structure to hold the needed information for a stack */
struct Stack_s
{
void *data[MAX_STACK_SIZE];
uint32 top;
uint8 empty;
};
typedef struct Stack_s Stack;
/**
Intializes (or reinitializes) a stack
@param stack Pointer to the stack
*/
void StackInitStack(Stack * stack);
/**
Pops off the top values on the stack
@param stack Pointer to the stack
@return Top value of the stack or NULL if the stack is empty
*/
void * StackPop(Stack * stack);
/**
Returns the top value without popping it off
@param stack Pointer to stack
@return Top element in stack
*/
void * StackPeek(Stack * stack);
/**
Pushes an element onto the stack
@param stack Pointer to the stack
@param ptr Pointer to push
@note If the stack is full, the item is not pushed
*/
void StackPush(Stack * stack, void * ptr);
/**
Boolean function to determine if the stack is full
@param stack Pointer to stack
@return 1 if full, 0 otherwise
*/
uint8 StackIsFull(Stack * stack);
/**
Boolean function to determine if the stack is empty
@param stack Pointer to stack
@return 1 if empty, 0 otherwise
*/
uint8 StackIsEmpty(Stack * stack);
/**
Returns the number of entries in the stack
@param stack Pointer to the stack
@return Number of entries in the stack
*/
uint32 StackNumEntries(Stack * stack);