Figure 1 Pseudocode for memory-tracing capability used for debugging and error reporting

static char *names_allocated[MAX_ALLOCATIONS];
static unsigned int sizes_allocated[MAX_ALLOCATIONS];
static unsigned long addresses_allocated[MAX_ALLOCATIONS];

void *memory_allocate(unsigned int size, char *name)
     {
     // Call malloc with size
     // if okay, then store name, size, address in arrays
     //   return address
     // else, print error message with name
     //   optionally, print all names, sizes, addresses
     }

void memory_free(void *address, char *name)
     {
     // If address == NULL
     //   print error message with name
     // else find address in array
     //   if not found
     //        print error message with name
     //   else
     //        clear array elements
     }