/* Smartalloc.h Copyright Clinton Staley 1991 * * Smartalloc provides an malloc version which checks for several possible * errors: * * 1. Failure of malloc call for any reason * 2. Attempt to free memory not allocated by malloc, or already freed. * 3. Writing past the end of malloc-ed memory * 4. Failure to free memory by some point in the program. * * Use smartalloc by including smartalloc.h in any file that calls malloc * or free. Also, compile smartalloc.c along with your other .c files. * If you make any of errors 1-3 above, smartalloc will report the error * and the file/line on which it occured. To find out if you have left * memory unfreed, call report_space(). If any unfreed memory is * outstanding, report_space will report the number of bytes of unfreed * memory. If no memory is unfreed, report_space remains silent. * * All rights to this package are reserved by its author. Duplication of * source or object code is permitted only with the author's permission. */ #define malloc(x) smartalloc((x), __FILE__, __LINE__) #define free(x) smartfree((x), __FILE__, __LINE__) char *smartalloc(long, char *, int); void smartfree(char *, char *, int); int report_space();