-
Notifications
You must be signed in to change notification settings - Fork 0
/
callStack.c.old
64 lines (54 loc) · 895 Bytes
/
callStack.c.old
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
#include <stdio.h>
#include <stdlib.h>
#include "callStack.h"
node *top = NULL;
void callStack_initialize()
{
//printf("zzzzzzz");
top = NULL;
}
//void callStack_push(functionData value)
void callStack_push()
{
node *tmp;
tmp = malloc(sizeof(node));
if (tmp == NULL)
{
printf("malloc fail");
}
//tmp -> data = value;
tmp -> next = top;
if (top != NULL)
{
//printf("XXXXXXXXX");
tmp -> nodeCount = top -> nodeCount + 1;
}
else
{
//printf("yyyyyyyyyyy");
tmp -> nodeCount = 1;
}
top = tmp;
}
functionData callStack_pop()
{
node *tmp;
functionData n;
tmp = top;
n = tmp->data;
top = top->next;
free(tmp);
return n;
}
functionData* callStack_top()
{
return &(top->data);
}
int callStack_isEmpty()
{
return top==NULL;
}
short callStack_Size()
{
return top -> nodeCount;
}