forgot to add the chkalloc files
[dos_imgv] / src / chkalloc.h
diff --git a/src/chkalloc.h b/src/chkalloc.h
new file mode 100644 (file)
index 0000000..4375d2c
--- /dev/null
@@ -0,0 +1,26 @@
+#ifndef CHKALLOC_H_
+#define CHKALLOC_H_
+
+#ifdef CHECK_ALLOC
+
+void chk_check(void);
+
+#define chk_malloc(sz)         chk_malloc_impl(sz, __FILE__, __LINE__)
+#define chk_realloc(p, sz)     chk_realloc_impl(p, sz, __FILE__, __LINE__)
+
+void *chk_malloc_impl(int sz, char *file, int line);
+void *chk_realloc_impl(void *ptr, int sz, char *file, int line);
+void chk_free(void *p);
+
+#else  /* !CHECK_ALLOC */
+
+#include <stdlib.h>
+
+#define chk_check()
+#define chk_malloc(sz)         malloc(sz)
+#define chk_realloc(p, sz)     realloc(p, sz)
+#define chk_free(p)                    free(p)
+
+#endif /* CHECK_ALLOC */
+
+#endif /* CHKALLOC_H_ */