Back to index

tetex-bin  3.0
Defines | Functions
xalloc.h File Reference
#include <stddef.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define __attribute__(x)
#define ATTRIBUTE_NORETURN   __attribute__ ((__noreturn__))
#define xalloc_oversized(n, s)   ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n))
#define CCLONE(p, n)   xclone (p, (n) * sizeof *(p))
#define CLONE(p)   xclone (p, sizeof *(p))
#define NEW(type, var)   type *var = xmalloc (sizeof (type))
#define XCALLOC(type, n)   xcalloc (n, sizeof (type))
#define XMALLOC(type, n)   xnmalloc (n, sizeof (type))
#define XREALLOC(p, type, n)   xnrealloc (p, n, sizeof (type))
#define XFREE(p)   free (p)

Functions

void xalloc_die (void) ATTRIBUTE_NORETURN
voidxmalloc (size_t s)
voidxnmalloc (size_t n, size_t s)
voidxzalloc (size_t s)
voidxcalloc (size_t n, size_t s)
voidxrealloc (void *p, size_t s)
voidxnrealloc (void *p, size_t n, size_t s)
voidx2realloc (void *p, size_t *pn)
voidx2nrealloc (void *p, size_t *pn, size_t s)
voidxclone (void const *p, size_t s)
char * xstrdup (const char *str)

Define Documentation

#define __attribute__ (   x)

Definition at line 33 of file xalloc.h.

#define ATTRIBUTE_NORETURN   __attribute__ ((__noreturn__))

Definition at line 38 of file xalloc.h.

#define CCLONE (   p,
  n 
)    xclone (p, (n) * sizeof *(p))

Definition at line 76 of file xalloc.h.

#define CLONE (   p)    xclone (p, sizeof *(p))

Definition at line 77 of file xalloc.h.

#define NEW (   type,
  var 
)    type *var = xmalloc (sizeof (type))

Definition at line 78 of file xalloc.h.

#define xalloc_oversized (   n,
  s 
)    ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n))

Definition at line 71 of file xalloc.h.

#define XCALLOC (   type,
  n 
)    xcalloc (n, sizeof (type))

Definition at line 79 of file xalloc.h.

#define XFREE (   p)    free (p)

Definition at line 82 of file xalloc.h.

#define XMALLOC (   type,
  n 
)    xnmalloc (n, sizeof (type))

Definition at line 80 of file xalloc.h.

#define XREALLOC (   p,
  type,
  n 
)    xnrealloc (p, n, sizeof (type))

Definition at line 81 of file xalloc.h.


Function Documentation

void* x2nrealloc ( void p,
size_t pn,
size_t  s 
)
void* x2realloc ( void p,
size_t pn 
)
void* xcalloc ( size_t  n,
size_t  s 
)
void* xclone ( void const p,
size_t  s 
)
void* xmalloc ( size_t  s)

Definition at line 36 of file xmalloc.c.

{
  void *temp = malloc (bytes);

  if (!temp)
    memory_error_and_abort ("xmalloc");
  return (temp);
}

Here is the call graph for this function:

void* xnmalloc ( size_t  n,
size_t  s 
)
void* xnrealloc ( void p,
size_t  n,
size_t  s 
)
void* xrealloc ( void p,
size_t  s 
)

Definition at line 46 of file xmalloc.c.

{
  void *temp;

  if (!pointer)
    temp = malloc (bytes);
  else
    temp = realloc (pointer, bytes);

  if (!temp)
    memory_error_and_abort ("xrealloc");

  return (temp);
}

Here is the call graph for this function:

char* xstrdup ( const char *  str)

Definition at line 733 of file util.c.

{
    size_t len;
    char *new;

    ASSERT(fprintf(stderr, "Test assertion!\n") && 1 == 0);
    ASSERT(str != NULL, "");
    len = strlen(str) + 1;
    new = xmalloc(len);
    memcpy(new, str, len);
    return new;
}

Here is the call graph for this function:

void* xzalloc ( size_t  s)