Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Examples  

test_dmalloc.c

This file shows how to use the functions of the dmalloc library.

#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;
}

Generated on Thu Apr 3 16:23:40 2003 for Common_C_libraries by doxygen1.3-rc1