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 ** sRefList.c (from slist_template.c)
28 # include "splintMacros.nf"
34 return sRefList_undefined
;
37 static /*@only@*/ /*@notnull@*/ sRefList
38 sRefList_newEmpty (void)
40 sRefList s
= (sRefList
) dmalloc (sizeof (*s
));
43 s
->nspace
= sRefListBASESIZE
;
44 s
->elements
= (sRef
*) dmalloc (sizeof (*s
->elements
) * sRefListBASESIZE
);
49 /*@only@*/ sRefList
sRefList_single (sRef el
)
51 sRefList res
= sRefList_newEmpty ();
52 res
= sRefList_add (res
, el
);
57 sRefList_grow (/*@notnull@*/ sRefList s
)
60 sRef
*oldelements
= s
->elements
;
62 s
->nspace
+= sRefListBASESIZE
;
64 s
->elements
= (sRef
*) dmalloc (sizeof (*s
->elements
) * (s
->nelements
+ s
->nspace
));
66 for (i
= 0; i
< s
->nelements
; i
++)
68 s
->elements
[i
] = oldelements
[i
];
74 /*@notnull@*/ sRefList
sRefList_add (sRefList s
, sRef el
)
76 if (sRefList_isUndefined (s
))
78 s
= sRefList_newEmpty ();
85 s
->elements
[s
->nelements
] = el
;
91 sRefList
sRefList_copy (sRefList s
)
93 sRefList t
= sRefList_new ();
95 sRefList_elements (s
, current
)
97 t
= sRefList_add (t
, sRef_copy (current
));
98 } end_sRefList_elements
;
104 sRefList_unparse (sRefList s
)
107 cstring st
= cstring_undefined
;
109 if (sRefList_isDefined (s
))
111 for (i
= 0; i
< sRefList_size (s
); i
++)
115 st
= message ("%q%q ", st
, sRef_unparse (s
->elements
[i
]));
118 st
= message ("%q%q ", st
, sRef_unparse (s
->elements
[i
]));
125 int sRefList_size (sRefList s
)
127 if (sRefList_isUndefined (s
)) return 0;
132 sRefList_free (/*@only@*/ sRefList s
)
134 if (sRefList_isDefined (s
))