]> andersk Git - splint.git/blame - src/qualList.c
Moved doc/lclint.1 to doc/splint.1
[splint.git] / src / qualList.c
CommitLineData
616915dd 1/*
11db3170 2** Splint - annotation-assisted static program checker
77d37419 3** Copyright (C) 1994-2002 University of Virginia,
616915dd 4** Massachusetts Institute of Technology
5**
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.
10**
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.
15**
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.
19**
155af98d 20** For information on splint: info@splint.org
21** To report a bug: splint-bug@splint.org
11db3170 22** For more information: http://www.splint.org
616915dd 23*/
24/*
25** qualList.c (from slist_template.c)
26*/
27
1b8ae690 28# include "splintMacros.nf"
616915dd 29# include "basic.h"
30
31qualList
32qualList_new ()
33{
34 return qualList_undefined;
35}
36
37static /*@only@*/ /*@notnull@*/ qualList
38qualList_newEmpty (void)
39{
40 qualList s = (qualList) dmalloc (sizeof (*s));
41
42 s->nelements = 0;
43 s->free = qualListBASESIZE;
44 s->elements = (qual *) dmalloc (sizeof (*s->elements) * qualListBASESIZE);
45
46 return (s);
47}
48
49void
50qualList_clear (qualList q)
51{
52 if (qualList_isDefined (q))
53 {
54 q->free += q->nelements;
55 q->nelements = 0;
56 }
57}
58
59static void
60qualList_grow (/*@notnull@*/ qualList s)
61{
62 int i;
63 qual *oldelements = s->elements;
64
65 s->free += qualListBASESIZE;
66
67 s->elements = (qual *) dmalloc (sizeof (*s->elements) * (s->nelements + s->free));
68
69 for (i = 0; i < s->nelements; i++)
70 {
71 s->elements[i] = oldelements[i];
72 }
73
74 sfree (oldelements);
75}
76
77qualList qualList_add (qualList s, qual el)
78{
79 if (qualList_isUndefined (s))
80 {
81 s = qualList_newEmpty ();
82 }
83
84 if (s->free <= 0)
85 qualList_grow (s);
86
87 s->free--;
88 s->elements[s->nelements] = el;
89 s->nelements++;
90
91 return (s);
92}
93
94qualList qualList_appendList (qualList s, qualList t)
95{
96 qualList_elements (t, current)
97 {
98 s = qualList_add (s, current);
99 } end_qualList_elements;
100
101 return s;
102}
103
104# ifndef NOLCL
105qualList qualList_copy (qualList s)
106{
107 qualList t = qualList_new ();
108
109 qualList_elements (s, current)
110 {
111 t = qualList_add (t, current);
112 } end_qualList_elements;
113
114 return t;
115}
116# endif
117
118/*@only@*/ cstring
119qualList_unparse (qualList s)
120{
121 int i;
122 cstring st = cstring_undefined;
123
124 if (qualList_isDefined (s))
125 {
126 for (i = 0; i < qualList_size (s); i++)
127 {
128 if (i == 0)
129 {
130 st = message ("%q%s ", st, qual_unparse (s->elements[i]));
131 }
132 else
133 st = message ("%q%s ", st, qual_unparse (s->elements[i]));
134 }
135 }
136
137 return st;
138}
139
140# ifndef NOLCL
141/*@only@*/ cstring
142qualList_toCComments (qualList s)
143{
144 int i;
145 cstring st = cstring_undefined;
146
147 if (qualList_isDefined (s))
148 {
149 for (i = 0; i < qualList_size (s); i++)
150 {
151 if (i == 0)
152 {
153 st = message ("%q/*@%s@*/ ", st, qual_unparse (s->elements[i]));
154 }
155 else
156 st = message ("%q/*@%s@*/ ", st, qual_unparse (s->elements[i]));
157 }
158 }
159
160 return st;
161}
162# endif
163
164bool
165qualList_hasAliasQualifier (qualList s)
166{
167 if (qualList_isDefined (s))
168 {
169 qualList_elements (s, q)
170 {
171 if (qual_isAliasQual (q)) return TRUE;
172 } end_qualList_elements;
173 }
174
175 return FALSE;
176}
177
178bool
179qualList_hasExposureQualifier (qualList s)
180{
181 if (qualList_isDefined (s))
182 {
183 qualList_elements (s, q)
184 {
185 if (qual_isExQual (q)) return TRUE;
186 } end_qualList_elements;
187 }
188
189 return FALSE;
190}
191
192void
193qualList_free (/*@only@*/ qualList s)
194{
195 if (qualList_isDefined (s))
196 {
197 sfree (s->elements);
198 sfree (s);
199 }
200}
201
202/* start modifications */
203/*
204requires: p is defined
205returns: true if qual is present in qualList
206modifies: none
207*/
28bf4b0b 208bool qualList_hasNullTerminatedQualifier(qualList s) {
209 qualList_elements(s, qu) {
210 if( qual_isNullTerminated(qu) ) return TRUE;
616915dd 211 } end_qualList_elements ;
212
213 return FALSE;
214}
215
216/* end modification/s */
217
218
This page took 0.10203 seconds and 5 git commands to generate.