annotate lwlib/lw_stack.h @ 425:67815606c5d9 3.0-beta2

Prevent NULL deref in lw_expr_destroy
author lost@l-w.ca
date Sun, 19 Sep 2010 10:27:47 -0600
parents c15cca3ae6a2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
329
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
1 /*
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
2 lw_stack.h
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
3
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
4 Copyright © 2010 William Astle
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
5
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
6 This file is part of LWTOOLS.
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
7
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
8 LWTOOLS is free software: you can redistribute it and/or modify it under the
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
9 terms of the GNU General Public License as published by the Free Software
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
10 Foundation, either version 3 of the License, or (at your option) any later
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
11 version.
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
12
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
13 This program is distributed in the hope that it will be useful, but WITHOUT
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
16 more details.
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
17
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
18 You should have received a copy of the GNU General Public License along with
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
19 this program. If not, see <http://www.gnu.org/licenses/>.
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
20 */
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
21
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
22 #ifndef ___lw_stack_h_seen___
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
23 #define ___lw_stack_h_seen___
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
24
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
25
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
26 #ifdef ___lw_stack_c_seen___
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
27
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
28 struct lw_stack_node_priv
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
29 {
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
30 void *data;
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
31 struct lw_stack_node_priv *next;
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
32 };
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
33
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
34 struct lw_stack_priv
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
35 {
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
36 struct lw_stack_node_priv *head;
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
37 void (*freefn)(void *d);
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
38 };
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
39
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
40 typedef struct lw_stack_priv * lw_stack_t;
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
41
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
42 #else /* def ___lw_stack_c_seen___ */
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
43
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
44 typedef void * lw_stack_t;
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
45 extern lw_stack_t lw_stack_create(void (*freefn)(void *d));
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
46 extern void lw_stack_destroy(lw_stack_t S);
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
47 extern void *lw_stack_top(lw_stack_t S);
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
48 extern void *lw_stack_pop(lw_stack_t S);
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
49 extern void lw_stack_push(lw_stack_t S, void *item);
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
50
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
51 #endif /* def ___lw_stack_c_seen___ */
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
52
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
53 #endif /* ___lw_stack_h_seen___ */