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"
36 ** redefine undef'd memory ops
43 ** all memory should be allocated from dimalloc
46 /*@out@*/ void *dimalloc (size_t size
, const char *name
, int line
)
47 /*@ensures maxSet(result) == (size - 1); @*/
49 /* was malloc, use calloc to initialize to zero */
50 void *ret
= (void *) calloc (1, size
);
56 llcontbug (message ("Zero allocation at %q.",
57 fileloc_unparseRaw (cstring_fromChars (name
), line
)));
61 ** Return some allocated storage...hope we get lucky.
64 return dimalloc (16, name
, line
);
68 /* drl fix this so message doesn't run out of memory*/
70 llbuglit("Out of memory");
73 (message ("Out of memory. Allocating %w bytes at %s:%d.",
74 size_toLongUnsigned (size
),
75 cstring_fromChars (name
), line
));
80 /*@-null@*/ /* null okay for size = 0 */
85 void *dicalloc (size_t num
, size_t size
, const char *name
, int line
)
87 void *ret
= (void *) calloc (num
, size
);
92 (message ("Out of memory. Allocating %w bytes at %s:%d.",
93 size_toLongUnsigned (size
),
94 cstring_fromChars (name
), line
));
100 void *direalloc (/*@out@*/ /*@null@*/ void *x
, size_t size
,
101 const char *name
, int line
)
107 ret
= (void *) dmalloc (size
);
111 ret
= (void *) realloc (x
, size
);
117 (message ("Out of memory. Allocating %w bytes at %s:%d.",
118 size_toLongUnsigned (size
),
119 cstring_fromChars (name
), line
));
125 void sfreeEventually (void *x
)
129 ; /* should keep in a table */