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
25 ** qualList.c (from slist_template.c)
28 # include "splintMacros.nf"
34 return qualList_undefined;
37 static /*@only@*/ /*@notnull@*/ qualList
38 qualList_newEmpty (void)
40 qualList s = (qualList) dmalloc (sizeof (*s));
43 s->free = qualListBASESIZE;
44 s->elements = (qual *) dmalloc (sizeof (*s->elements) * qualListBASESIZE);
50 qualList_clear (qualList q)
52 if (qualList_isDefined (q))
54 q->free += q->nelements;
60 qualList_grow (/*@notnull@*/ qualList s)
63 qual *oldelements = s->elements;
65 s->free += qualListBASESIZE;
67 s->elements = (qual *) dmalloc (sizeof (*s->elements) * (s->nelements + s->free));
69 for (i = 0; i < s->nelements; i++)
71 s->elements[i] = oldelements[i];
77 qualList qualList_single (qual el)
79 /*@-unqualifiedtrans@*/ /* must be only */
80 return (qualList_add (qualList_undefined, el));
81 /*@=unqualifiedtrans@*/
84 qualList qualList_add (qualList s, qual el)
86 if (qualList_isUndefined (s))
88 s = qualList_newEmpty ();
95 s->elements[s->nelements] = el;
101 qualList qualList_appendList (qualList s, qualList t)
103 qualList_elements (t, current)
105 s = qualList_add (s, current);
106 } end_qualList_elements;
111 qualList qualList_copy (qualList s)
113 qualList t = qualList_new ();
115 qualList_elements (s, current)
117 t = qualList_add (t, current);
118 } end_qualList_elements;
124 qualList_unparse (qualList s)
127 cstring st = cstring_undefined;
129 if (qualList_isDefined (s))
131 for (i = 0; i < qualList_size (s); i++)
135 st = message ("%q%s ", st, qual_unparse (s->elements[i]));
138 st = message ("%q%s ", st, qual_unparse (s->elements[i]));
146 qualList_toCComments (qualList s)
149 cstring st = cstring_undefined;
151 if (qualList_isDefined (s))
153 for (i = 0; i < qualList_size (s); i++)
157 st = message ("%q/*@%s@*/ ", st, qual_unparse (s->elements[i]));
160 st = message ("%q/*@%s@*/ ", st, qual_unparse (s->elements[i]));
168 qualList_hasAliasQualifier (qualList s)
170 if (qualList_isDefined (s))
172 qualList_elements (s, q)
174 if (qual_isAliasQual (q)) return TRUE;
175 } end_qualList_elements;
182 qualList_hasExposureQualifier (qualList s)
184 if (qualList_isDefined (s))
186 qualList_elements (s, q)
188 if (qual_isExQual (q)) return TRUE;
189 } end_qualList_elements;
196 qualList_free (/*@only@*/ qualList s)
198 if (qualList_isDefined (s))
205 /* start modifications */
207 requires: p is defined
208 returns: true if qual is present in qualList
211 bool qualList_hasNullTerminatedQualifier(qualList s) {
212 qualList_elements(s, qu) {
213 if( qual_isNullTerminated(qu) ) return TRUE;
214 } end_qualList_elements ;
219 /* end modification/s */