blob: 272732f1d082c96e06ac0de598a6d781ab94013f (
plain)
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
|
#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
|