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
28 # include "splintMacros.nf"
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
));
41 res
->rest
= pointers_undefined
;
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
));
61 res
->rest
= pointers_undefined
;
66 pointers
pointers_createModsLt (/*@unused@*/ ltoken tok
, qualList quals
)
68 pointers res
= (pointers
) dmalloc (sizeof (*res
));
71 res
->rest
= pointers_undefined
;
76 pointers
pointers_extend (pointers p1
, pointers p2
)
78 llassert (pointers_isDefined (p1
));
79 llassert (pointers_isUndefined (p1
->rest
));
84 pointers
pointers_getRest (pointers p
)
86 llassert (pointers_isDefined (p
));
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
)));
102 return (message ("* %q", qualList_unparse (p
->quals
)));
107 if (pointers_isDefined (p
->rest
))
109 return (message ("* %q", pointers_unparse (p
->rest
)));
113 return (cstring_makeLiteral ("*"));
119 return cstring_undefined
;
123 int pointers_depth (pointers p
)
125 if (pointers_isUndefined (p
))
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
);