Back to index

tetex-bin  3.0
gmem.h
Go to the documentation of this file.
00001 /*
00002  * gmem.h
00003  *
00004  * Memory routines with out-of-memory checking.
00005  *
00006  * Copyright 1996-2003 Glyph & Cog, LLC
00007  */
00008 
00009 #ifndef GMEM_H
00010 #define GMEM_H
00011 
00012 #include <stdio.h>
00013 
00014 #ifdef __cplusplus
00015 extern "C" {
00016 #endif
00017 
00018 /*
00019  * Same as malloc, but prints error message and exits if malloc()
00020  * returns NULL.
00021  */
00022 extern void *gmalloc(int size);
00023 
00024 /*
00025  * Same as realloc, but prints error message and exits if realloc()
00026  * returns NULL.  If <p> is NULL, calls malloc instead of realloc().
00027  */
00028 extern void *grealloc(void *p, int size);
00029 
00030 /*
00031  * Same as free, but checks for and ignores NULL pointers.
00032  */
00033 extern void gfree(void *p);
00034 
00035 #ifdef DEBUG_MEM
00036 /*
00037  * Report on unfreed memory.
00038  */
00039 extern void gMemReport(FILE *f);
00040 #else
00041 #define gMemReport(f)
00042 #endif
00043 
00044 /*
00045  * Allocate memory and copy a string into it.
00046  */
00047 extern char *copyString(char *s);
00048 
00049 #ifdef __cplusplus
00050 }
00051 #endif
00052 
00053 #endif