-
Notifications
You must be signed in to change notification settings - Fork 1
/
pointerstack.h
43 lines (34 loc) · 1.04 KB
/
pointerstack.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
/*****************************************************************************************
*
* IFJ - interpret of IFJ15 language
*
* pointer stack header
* stack to calling functions in interpret or for temp variables
*
* author: Libor Janíček (xjanic21)
* created: 2015-11-16
* modified: 2015-11-16
*
*****************************************************************************************/
#ifndef ADR_STACK_H
#define ADR_STACK_H
// structure of stack item
typedef struct pointerStackItem {
void *data;
struct pointerStackItem *next;
} pointerStackItem_T;
// stack structure
typedef struct {
pointerStackItem_T *top;
} pointerStack_T;
// init 'stack'
void initPS(pointerStack_T *stack);
// destroy 'stack' and free allocated memory
void destroyPS(pointerStack_T *stack);
// add new item with 'data' to 'stack'
int pushPS(pointerStack_T *stack, void *data);
// delete item on top from 'stack' and free allocated memory
void popPS(pointerStack_T *stack);
// return data of item on top 'stack'
void *topPS(pointerStack_T *stack);
#endif