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
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_add (qualList s, qual el)
79 if (qualList_isUndefined (s))
81 s = qualList_newEmpty ();
88 s->elements[s->nelements] = el;
94 qualList qualList_appendList (qualList s, qualList t)
96 qualList_elements (t, current)
98 s = qualList_add (s, current);
99 } end_qualList_elements;
105 qualList qualList_copy (qualList s)
107 qualList t = qualList_new ();
109 qualList_elements (s, current)
111 t = qualList_add (t, current);
112 } end_qualList_elements;
119 qualList_unparse (qualList s)
122 cstring st = cstring_undefined;
124 if (qualList_isDefined (s))
126 for (i = 0; i < qualList_size (s); i++)
130 st = message ("%q%s ", st, qual_unparse (s->elements[i]));
133 st = message ("%q%s ", st, qual_unparse (s->elements[i]));
142 qualList_toCComments (qualList s)
145 cstring st = cstring_undefined;
147 if (qualList_isDefined (s))
149 for (i = 0; i < qualList_size (s); i++)
153 st = message ("%q/*@%s@*/ ", st, qual_unparse (s->elements[i]));
156 st = message ("%q/*@%s@*/ ", st, qual_unparse (s->elements[i]));
165 qualList_hasAliasQualifier (qualList s)
167 if (qualList_isDefined (s))
169 qualList_elements (s, q)
171 if (qual_isAliasQual (q)) return TRUE;
172 } end_qualList_elements;
179 qualList_hasExposureQualifier (qualList s)
181 if (qualList_isDefined (s))
183 qualList_elements (s, q)
185 if (qual_isExQual (q)) return TRUE;
186 } end_qualList_elements;
193 qualList_free (/*@only@*/ qualList s)
195 if (qualList_isDefined (s))
202 /* start modifications */
204 requires: p is defined
205 returns: true if qual is present in qualList
208 bool qualList_hasNullTerminatedQualifier(qualList s) {
209 qualList_elements(s, qu) {
210 if( qual_isNullTerminated(qu) ) return TRUE;
211 } end_qualList_elements ;
216 /* end modification/s */