2 ** Splint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2002 University of Virginia,
4 ** Massachusetts Institute of Technology
6 ** This program is free software; you can redistribute it and/or modify it
7 ** under the terms of the GNU General Public License as published by the
8 ** Free Software Foundation; either version 2 of the License, or (at your
9 ** option) any later version.
11 ** This program is distributed in the hope that it will be useful, but
12 ** WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ** General Public License for more details.
16 ** The GNU General Public License is available from http://www.gnu.org/ or
17 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 ** MA 02111-1307, USA.
20 ** For information on splint: splint@cs.virginia.edu
21 ** To report a bug: splint-bug@cs.virginia.edu
22 ** For more information: http://www.splint.org
27 ** based on list_template.c
29 ** where T has T_equal (or change this) and T_unparse
32 # include "splintMacros.nf"
35 /*@only@*/ paramNodeList
38 paramNodeList s = (paramNodeList) dmalloc (sizeof (*s));
41 s->nspace = paramNodeListBASESIZE;
42 s->elements = (paramNode *)
43 dmalloc (sizeof (*s->elements) * paramNodeListBASESIZE);
48 /*@only@*/ paramNodeList
49 paramNodeList_single (/*@keep@*/ paramNode p)
51 paramNodeList s = (paramNodeList) dmalloc (sizeof (*s));
54 s->nspace = paramNodeListBASESIZE - 1;
55 s->elements = (paramNode *) dmalloc (sizeof (*s->elements) * paramNodeListBASESIZE);
62 paramNodeList_grow (/*@notnull@*/ paramNodeList s)
65 paramNode *newelements;
67 s->nspace += paramNodeListBASESIZE;
69 newelements = (paramNode *) dmalloc (sizeof (*newelements)
70 * (s->nelements + s->nspace));
72 for (i = 0; i < s->nelements; i++)
74 newelements[i] = s->elements[i];
78 s->elements = newelements;
82 paramNodeList_add (paramNodeList s, paramNode el)
84 llassert (paramNodeList_isDefined (s));
87 paramNodeList_grow (s);
90 s->elements[s->nelements] = el;
96 /*@only@*/ paramNodeList
97 paramNodeList_copy (paramNodeList s)
99 paramNodeList r = paramNodeList_new ();
101 paramNodeList_elements (s, x)
103 r = paramNodeList_add (r, paramNode_copy (x));
104 } end_paramNodeList_elements;
110 paramNodeList_unparse (paramNodeList s)
113 cstring st = cstring_undefined;
115 paramNodeList_elements (s, current)
119 st = paramNode_unparse (current);
124 st = message ("%q, %q", st, paramNode_unparse (current));
126 } end_paramNodeList_elements;
132 paramNodeList_unparseComments (paramNodeList s)
135 cstring st = cstring_undefined;
137 paramNodeList_elements (s, current)
141 st = paramNode_unparseComments (current);
146 st = message ("%q, %q", st, paramNode_unparseComments (current));
148 } end_paramNodeList_elements;
154 paramNodeList_free (/*@only@*/ paramNodeList s)
156 if (paramNodeList_isDefined (s))
159 for (i = 0; i < s->nelements; i++)
161 paramNode_free (s->elements[i]);