2 ** Splint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2003 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"
36 /*@constant int exprNodeSListBASESIZE;@*/
37 # define exprNodeSListBASESIZE SMALLBASESIZE
40 exprNodeSList_new (void)
42 exprNodeSList s
= (exprNodeSList
) dmalloc (sizeof (*s
));
45 s
->nspace
= exprNodeSListBASESIZE
;
46 s
->elements
= (exprNode
*)
47 dmalloc (sizeof (*s
->elements
) * exprNodeSListBASESIZE
);
53 exprNodeSList_grow (exprNodeSList s
)
56 exprNode
*newelements
;
58 s
->nspace
+= exprNodeSListBASESIZE
;
60 newelements
= (exprNode
*) dmalloc (sizeof (*newelements
)
61 * (s
->nelements
+ s
->nspace
));
63 if (newelements
== (exprNode
*) 0)
65 llfatalerror (cstring_makeLiteral ("exprNodeSList_grow: out of memory!"));
68 for (i
= 0; i
< s
->nelements
; i
++)
70 newelements
[i
] = s
->elements
[i
];
74 s
->elements
= newelements
;
77 static /*@unused@*/ void exprNodeSList_addh (exprNodeSList s
, /*@exposed@*/ /*@dependent@*/ exprNode el
)
79 llassert (exprNodeSListBASESIZE
> 0);
82 exprNodeSList_grow (s
);
85 s
->elements
[s
->nelements
] = el
;
93 exprNodeSList
exprNodeSList_append (/*@returned@*/ exprNodeSList s1
, /*@only@*/ exprNodeSList s2
)
95 exprNodeSList_elements (s2
, x
)
97 exprNodeSList_addh (s1
, x
);
98 } end_exprNodeSList_elements
;
100 exprNodeSList_free (s2
);
104 /*@only@*/ exprNodeSList
exprNodeSList_singleton (/*@exposed@*/ /*@dependent@*/ exprNode e
)
106 exprNodeSList s
= (exprNodeSList
) dmalloc (sizeof (*s
));
109 s
->nspace
= exprNodeSListBASESIZE
- 1;
110 s
->elements
= (exprNode
*) dmalloc (sizeof (*s
->elements
) * exprNodeSListBASESIZE
);
118 exprNodeSList_unparse (exprNodeSList s
)
121 cstring st
= cstring_undefined
;
123 for (i
= 0; i
< s
->nelements
; i
++)
127 st
= cstring_copy (exprNode_unparse (s
->elements
[i
]));
130 st
= message ("%q, %s", st
, exprNode_unparse (s
->elements
[i
]));
135 # endif /* DEADCODE */
138 exprNodeSList_free (exprNodeSList s
)