Back to index

tetex-bin  3.0
Functions
mem.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include "mem.h"

Go to the source code of this file.

Functions

voidnew (size_t size, char *function, int line)
voidrenew (void *mem, size_t size, char *function, int line)
void release (void *mem, char *function, int line)

Function Documentation

void* new ( size_t  size,
char *  function,
int  line 
)

Definition at line 45 of file mem.c.

{
  void *result;
  if ((result = malloc (size)) == NULL) {
    fprintf (stderr, "Out of memory in %s:%d\n", function, line);
    fprintf (stderr, "Asked for %lu\n", (unsigned long) size);
    exit (1);
  }

#ifdef MEM_DEBUG  
  mem_debug_init();
  event += 1;
  fprintf (debugfile, "%p %07ld [new] %s:%d\n", result, event, function, line);
#endif /* MEM_DEBUG */

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void release ( void mem,
char *  function,
int  line 
)

Definition at line 84 of file mem.c.

{

#ifdef MEM_DEBUG
    mem_debug_init();
    event += 1;
    fprintf (debugfile, "%p %07ld [fre] %s:%d\n", mem, event, function, line);
#endif /* MEM_DEBUG */

  free (mem);
}

Here is the call graph for this function:

void* renew ( void mem,
size_t  size,
char *  function,
int  line 
)

Definition at line 63 of file mem.c.

{
  void *result;
#ifdef MEM_DEBUG
    mem_debug_init();
    event += 1;
  if (mem)
    fprintf (debugfile, "%p %07ld [fre] %s:%d\n", mem,
            event, function, line);
#endif /* MEM_DEBUG */
  if ((result = realloc (mem, size)) == NULL) {
    fprintf (stderr, "Out of memory!\n");
    exit (1);
  }
#ifdef MEM_DEBUG
  if (result)
    fprintf (debugfile, "%p %07ld [new] %s:%d\n", result, event, function, line);
#endif /* MEM_DEBUG */
  return result;
}

Here is the call graph for this function: