4 * Memory routines with out-of-memory checking.
6 * Copyright 1996-2003 Glyph & Cog, LLC
23 #define GMEM_EXCEP throw(GMemException)
25 #else // USE_EXCEPTIONS
29 #endif // USE_EXCEPTIONS
36 * Same as malloc, but prints error message and exits if malloc()
39 extern void *gmalloc(int size
) GMEM_EXCEP
;
42 * Same as realloc, but prints error message and exits if realloc()
43 * returns NULL. If <p> is NULL, calls malloc instead of realloc().
45 extern void *grealloc(void *p
, int size
) GMEM_EXCEP
;
48 * These are similar to gmalloc and grealloc, but take an object count
49 * and size. The result is similar to allocating nObjs * objSize
50 * bytes, but there is an additional error check that the total size
51 * doesn't overflow an int.
53 extern void *gmallocn(int nObjs
, int objSize
) GMEM_EXCEP
;
54 extern void *greallocn(void *p
, int nObjs
, int objSize
) GMEM_EXCEP
;
57 * Same as free, but checks for and ignores NULL pointers.
59 extern void gfree(void *p
);
63 * Report on unfreed memory.
65 extern void gMemReport(FILE *f
);
71 * Allocate memory and copy a string into it.
73 extern char *copyString(char *s
);