Back to index

nagios-plugins  1.4.16
Defines | Enumerations | Functions
xmalloc.c File Reference
#include <config.h>
#include "xalloc.h"
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Defines

#define static_inline

Enumerations

enum  { HAVE_GNU_CALLOC = 0 }

Functions

void * xmalloc (size_t n)
void * xrealloc (void *p, size_t n)
void * x2realloc (void *p, size_t *pn)
void * xzalloc (size_t s)
void * xcalloc (size_t n, size_t s)
void * xmemdup (void const *p, size_t s)
char * xstrdup (char const *string)

Define Documentation

#define static_inline

Definition at line 23 of file xmalloc.c.


Enumeration Type Documentation

anonymous enum
Enumerator:
HAVE_GNU_CALLOC 

Definition at line 37 of file xmalloc.c.

{ HAVE_GNU_CALLOC = 0 };

Function Documentation

void* x2realloc ( void *  p,
size_t *  pn 
)

Definition at line 70 of file xmalloc.c.

{
  return x2nrealloc (p, pn, 1);
}

Here is the call graph for this function:

void* xcalloc ( size_t  n,
size_t  s 
)

Definition at line 89 of file xmalloc.c.

{
  void *p;
  /* Test for overflow, since some calloc implementations don't have
     proper overflow checks.  But omit overflow and size-zero tests if
     HAVE_GNU_CALLOC, since GNU calloc catches overflow and never
     returns NULL if successful.  */
  if ((! HAVE_GNU_CALLOC && xalloc_oversized (n, s))
      || (! (p = calloc (n, s)) && (HAVE_GNU_CALLOC || n != 0)))
    xalloc_die ();
  return p;
}

Here is the call graph for this function:

void* xmalloc ( size_t  n)

Definition at line 43 of file xmalloc.c.

{
  void *p = malloc (n);
  if (!p && n != 0)
    xalloc_die ();
  return p;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void* xmemdup ( void const p,
size_t  s 
)

Definition at line 107 of file xmalloc.c.

{
  return memcpy (xmalloc (s), p, s);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void* xrealloc ( void *  p,
size_t  n 
)

Definition at line 55 of file xmalloc.c.

{
  p = realloc (p, n);
  if (!p && n != 0)
    xalloc_die ();
  return p;
}

Here is the call graph for this function:

char* xstrdup ( char const string)

Definition at line 115 of file xmalloc.c.

{
  return xmemdup (string, strlen (string) + 1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void* xzalloc ( size_t  s)

Definition at line 80 of file xmalloc.c.

{
  return memset (xmalloc (s), 0, s);
}

Here is the call graph for this function: