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: info@splint.org
21 ** To report a bug: splint-bug@splint.org
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"
34 # include "exprNodeSList.h"
39 exprNodeSList s = (exprNodeSList) dmalloc (sizeof (*s));
42 s->nspace = exprNodeSListBASESIZE;
43 s->elements = (exprNode *)
44 dmalloc (sizeof (*s->elements) * exprNodeSListBASESIZE);
50 exprNodeSList_grow (exprNodeSList s)
53 exprNode *newelements;
55 s->nspace += exprNodeSListBASESIZE;
57 newelements = (exprNode *) dmalloc (sizeof (*newelements)
58 * (s->nelements + s->nspace));
60 if (newelements == (exprNode *) 0)
62 llfatalerror (cstring_makeLiteral ("exprNodeSList_grow: out of memory!"));
65 for (i = 0; i < s->nelements; i++)
67 newelements[i] = s->elements[i];
71 s->elements = newelements;
74 void exprNodeSList_addh (exprNodeSList s, /*@exposed@*/ /*@dependent@*/ exprNode el)
76 llassert (exprNodeSListBASESIZE > 0);
79 exprNodeSList_grow (s);
82 s->elements[s->nelements] = el;
90 exprNodeSList exprNodeSList_append (/*@returned@*/ exprNodeSList s1, /*@only@*/ exprNodeSList s2)
92 exprNodeSList_elements (s2, x)
94 exprNodeSList_addh (s1, x);
95 } end_exprNodeSList_elements;
97 exprNodeSList_free (s2);
101 /*@only@*/ exprNodeSList exprNodeSList_singleton (/*@exposed@*/ /*@dependent@*/ exprNode e)
103 exprNodeSList s = (exprNodeSList) dmalloc (sizeof (*s));
106 s->nspace = exprNodeSListBASESIZE - 1;
107 s->elements = (exprNode *) dmalloc (sizeof (*s->elements) * exprNodeSListBASESIZE);
114 exprNodeSList_unparse (exprNodeSList s)
117 cstring st = cstring_undefined;
119 for (i = 0; i < s->nelements; i++)
123 st = cstring_copy (exprNode_unparse (s->elements[i]));
126 st = message ("%q, %s", st, exprNode_unparse (s->elements[i]));
133 exprNodeSList_free (exprNodeSList s)