-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStack.h
More file actions
87 lines (79 loc) · 1.39 KB
/
Stack.h
File metadata and controls
87 lines (79 loc) · 1.39 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef STACK_H
#define STACK_H
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <stdio.h>
#define STACK_SIZE 6
#define STACK_NAME_SIZE 10
#ifdef _DEBUG
#define STACK_CANARY_SIZE 3
#endif
enum
{
STACK_OK,
STACK_OVERFLOW_ERR,
STACK_UNDERFLOW_ERR,
STACK_CORRUPTION_ERR,
STACK_NULL_POINTER_ERR
};
/*!
*double Stack
*/
typedef struct _Stack_d
{
#ifdef _DEBUG
char canary1[STACK_CANARY_SIZE];
char hash1;
#endif
//char name[STACK_NAME_SIZE];
size_t size = STACK_SIZE;
size_t position = 0;
double data[STACK_SIZE];
int errcode = 0;
#ifdef _DEBUG
char hash2;
char canary2[STACK_CANARY_SIZE];
#endif
} elStack_d, * Stack_d;
/*!
*Construct Stack_d
*returns Stack_d
*/
Stack_d ConstructStack_d();
/*!
*Initialization of Stack_d at address stk
*returns error value
*/
int InitElStack_d(elStack_d* stk);
/*!
*Push value to Stack_d
*returns error value
*/
int PushStack_d(Stack_d stk, double value);
/*!
*Pops last element of Stack stk and puts it at destination address
*returns error value
*/
int PopStack_d(Stack_d stk, double* destination);
/*!
*Destroys Stack_d stk
*returns error value
*/
int DestroyStack_d(Stack_d stk);
/*!
*Checks Stack_d stk for corruption
*returns error value
*/
int CheckStack_d(Stack_d stk);
/*!
*Prints dump of stk
*returns error value
*/
int DumpStack_d(Stack_d stk);
/*!
*Calculates hashsum of Stack_d stk
*returns hashsum
*/
char HashStack_d(Stack_d stk);
#endif