#include <stdio.h> #include "dmalloc.h" #define PMAX 100 int main() { void *p[PMAX]; int i; fprintf (stdout, "\n\nTesting the dmalloc library, result in file \"dmalloc.res\"\n"); fflush (stdout); for (i=0; i<PMAX; i++) { p[i] = dmalloc(128, "Allocate p", "dmalloc.res"); if (p[i] == NULL) { fprintf (stderr, "\nERROR: Can not allocate memory!\n"); return 1; } } for (i=0; i<PMAX; i++) { if (dfree(p[i], "free p", "dmalloc.res") != 0) { fprintf (stderr, "\nERROR: Can not allocate memory!\n"); return 1; } } return 0; }