diff options
author | Galin Simeonov <gts@volconst.com> | 2021-05-17 17:29:08 +0300 |
---|---|---|
committer | Galin Simeonov <gts@volconst.com> | 2021-07-15 18:00:15 +0300 |
commit | f768d9bdb84e846d89aac66a4f3433a44241c298 (patch) | |
tree | b7e8248bebd80c8b1f911f666260ad52b7213b84 /stack.c | |
parent | 679cbe58c4e53f0163588a7731154f3afe2d25aa (diff) | |
download | MEGATRON-f768d9bdb84e846d89aac66a4f3433a44241c298.tar.gz |
parser formed
Diffstat (limited to 'stack.c')
-rw-r--r-- | stack.c | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -0,0 +1,37 @@ +#ifndef GSTACK_C +#define GSTACK_C GSTACK_C +#include "stack.h" + + + +void Stack_Init(Stack *stack) +{ + stack->size=0; + stack->first=NULL; +} +void Stack_Push(Stack *stack,void* data) +{ + struct Stack_Node *temp_node=malloc(sizeof(struct Stack_Node)); + temp_node->data=data; + temp_node->next=stack->first; + stack->first=temp_node; + ++stack->size; +} +void* Stack_Pop(Stack *stack) +{ + void* return_value=NULL; + if(stack->first!=NULL) + { + struct Stack_Node *temp_first=stack->first; + return_value=stack->first->data; + + --stack->size; + stack->first=stack->first->next; + free(temp_first); + } + + return return_value; +} + +#endif//#ifndef GSTACK_C + |