3
/******************************************************\
4
* Description: the just sets the stack pointer to *
5
* NULL; it really has no business being *
7
\******************************************************/
8
void createStack(hexStack *stack)
10
/* calloc() is used because it NULLS out all returned memory */
11
/* stack = (hexStack *) calloc(1, sizeof(hexStack));
20
/******************************************************\
21
* Description: this pushes a structure of type *
22
* hexStack to the stack. NULL being the*
23
* initial state of the stack *
24
\******************************************************/
25
void pushStack(hexStack **stack, hexStack *tmpStack)
30
if (oldStack == NULL) /* begining of stack */
34
tmpStack->prev = oldStack;
41
/******************************************************\
42
* Description: This function pops a structure off of *
43
* the stack and then free's it's *
44
* previously allocated memory. If the *
45
* stack == NULL that means the bottom of*
46
* the stack has been reached. *
47
\******************************************************/
48
void popStack(hexStack **stack)
50
hexStack *tmpStack = *stack;
53
{ /* set to prev val in llist */
54
*stack = tmpStack->prev; /* pop off the stack */
55
free(tmpStack); /* free allocated memory */
60
/******************************************************\
61
* Description: This will pop off all values from the *
62
* stack and wil free all the allocated *
63
* memory avoiding potential memory leaks*
64
\******************************************************/
65
void smashDaStack(hexStack **stack)
67
hexStack *tmpStack = *stack;
69
while (tmpStack != NULL)
71
*stack = tmpStack->prev;