GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — expr-parser/stackobject.c at master · orbitz/expr-parser

Expand file tree

/

stackobject.c

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
105 lines (89 loc) · 1.72 KB
/

stackobject.c

Copy path

File metadata and controls

105 lines (89 loc) · 1.72 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include <stackobject.h>
/*
* Function - stack_init
* Return - Pointer to NULL
* Description - Returns a pointer to NULL
*/
struct STACKOBJECT *stack_init (void)
{
struct STACKOBJECT *this = NULL;
return this;
}
/*
* Function - stack_push
* Description - Push's data onto the stack
*/
boolean stack_push (struct STACKOBJECT ** this, const void *data,
const size_t size)
{
struct STACKOBJECT *curr;
curr = (struct STACKOBJECT *) malloc (sizeof (struct STACKOBJECT));
if (curr == NULL)
{
return FALSE;
}
curr->next = *this;
*this = curr;
curr->data = (char *) malloc (size);
if (curr->data == NULL)
{
return FALSE;
}
memcpy ((void *) curr->data, (void *) data, size);
curr->size = size;
return TRUE;
}
/*
* Function - stack_pop
* Return - Pointer to data that was on the stack
* Description - Returns a pointer to data on the stack
*/
char *stack_pop (struct STACKOBJECT **this)
{
struct STACKOBJECT *curr = *this;
char *data;
if (curr != NULL)
{
data = (char *) malloc ((size_t) curr->size);
memcpy (data, curr->data, (size_t) curr->size);
curr = (*this)->next;
free (*this);
*this = curr;
}
else
{
data = NULL;
}
return data;
}
/*
* Function - stack_isEmpty
* Return - TRUE or FALSE
* Description - Says if the function is empty or not
*/
boolean stack_isEmpty (const struct STACKOBJECT ** this)
{
boolean retval;
if (*this == NULL)
{
retval = TRUE;
}
else
{
retval = FALSE;
}
return retval;
}
/*
* Function - stack_destroy
* Description - Destroys a stack, sets the in stack to NULL when done
*/
void stack_destroy (struct STACKOBJECT **this)
{
while (!stack_isEmpty (this))
{
stack_pop (this);
}
free (*this);
*this = NULL;
}
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.