First part of transition from not-function header.
[splint-patched.git] / src / pointers.c
blob1580f9db82a8c4bf1753adc262b764fa9171077c
1 /*
2 ** Splint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2003 University of Virginia,
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.
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 ** pointers.c
28 # include "splintMacros.nf"
29 # include "basic.h"
31 pointers pointers_create (lltok tok)
33 return pointers_createMods (tok, qualList_undefined);
36 pointers pointers_createMods (/*@unused@*/ lltok tok, qualList quals)
38 pointers res = (pointers) dmalloc (sizeof (*res));
40 res->quals = quals;
41 res->rest = pointers_undefined;
43 return res;
46 pointers pointers_createMt (mttok tok)
48 return pointers_createModsMt (tok, qualList_undefined);
51 pointers pointers_createLt (ltoken tok)
53 return pointers_createModsLt (tok, qualList_undefined);
56 pointers pointers_createModsMt (/*@unused@*/ mttok tok, qualList quals)
58 pointers res = (pointers) dmalloc (sizeof (*res));
60 res->quals = quals;
61 res->rest = pointers_undefined;
63 return res;
66 pointers pointers_createModsLt (/*@unused@*/ ltoken tok, qualList quals)
68 pointers res = (pointers) dmalloc (sizeof (*res));
70 res->quals = quals;
71 res->rest = pointers_undefined;
73 return res;
76 pointers pointers_extend (pointers p1, pointers p2)
78 llassert (pointers_isDefined (p1));
79 llassert (pointers_isUndefined (p1->rest));
80 p1->rest = p2;
81 return p1;
84 pointers pointers_getRest (pointers p)
86 llassert (pointers_isDefined (p));
87 return p->rest;
90 cstring pointers_unparse (pointers p)
92 if (pointers_isDefined (p))
94 if (qualList_isDefined (p->quals))
96 if (pointers_isDefined (p->rest))
98 return (message ("* %q %q", qualList_unparse (p->quals), pointers_unparse (p->rest)));
100 else
102 return (message ("* %q", qualList_unparse (p->quals)));
105 else
107 if (pointers_isDefined (p->rest))
109 return (message ("* %q", pointers_unparse (p->rest)));
111 else
113 return (cstring_makeLiteral ("*"));
117 else
119 return cstring_undefined;
123 int pointers_depth (pointers p)
125 if (pointers_isUndefined (p))
127 return 0;
129 else
131 return 1 + pointers_depth (p->rest);
135 void pointers_free (/*@only@*/ pointers p)
137 if (pointers_isDefined (p))
139 qualList_free (p->quals);
140 pointers_free (p->rest);
141 sfree (p);