malloc-check.h File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Include dependency graph for malloc-check.h:

Go to the source code of this file.

Data Structures

struct  Malloc_check_vals
struct  Malloc_check_store

Defines

#define MALLOC_CHECK_H   1
#define MALLOC_CHECK__ATTR_USED()
#define MALLOC_CHECK__ATTR_H()
#define MALLOC_CHECK__ATTR_MALLOC()
#define MALLOC_CHECK_API_M_SCRUB   0
#define MALLOC_CHECK_API_F_SCRUB   0
#define MALLOC_CHECK_API_R_SCRUB   0
#define MALLOC_CHECK_STORE   malloc_check__app_store
#define MALLOC_CHECK_REINIT()
#define MALLOC_CHECK_INIT()
#define USE_MALLOC_CHECK   1
#define MALLOC_CHECK_FUNC_NAME   ""
#define MALLOC_CHECK_MEM(x)   malloc_check_mem(x, __FILE__, __LINE__, MALLOC_CHECK_FUNC_NAME)
#define MALLOC_CHECK_MEM_SZ(x, y)   malloc_check_mem_sz(x, y, __FILE__, __LINE__, MALLOC_CHECK_FUNC_NAME)
#define MALLOC_CHECK_MEM_MINSZ(x, y)   malloc_check_mem_minsz(x, y, __FILE__, __LINE__, MALLOC_CHECK_FUNC_NAME)
#define MALLOC_CHECK_EMPTY()   malloc_check_empty(__FILE__, __LINE__, MALLOC_CHECK_FUNC_NAME)
#define MC_MALLOC(x)   malloc_check_malloc(x, __FILE__, __LINE__, MALLOC_CHECK_FUNC_NAME)
#define MC_CALLOC(x, y)   malloc_check_calloc(x, y, __FILE__, __LINE__, MALLOC_CHECK_FUNC_NAME)
#define MC_REALLOC(x, y)   malloc_check_realloc(x, y, __FILE__, __LINE__, MALLOC_CHECK_FUNC_NAME)
#define MC_FREE(x)   malloc_check_free(x, __FILE__, __LINE__, MALLOC_CHECK_FUNC_NAME)
#define MALLOC_CHECK_SCOPE_EXTERN   1
#define malloc_check_assert(x)
#define MALLOC_CHECK_ASSERT(x)
#define MALLOC_CHECK_DECL()   Malloc_check_store MALLOC_CHECK_STORE = {0, 0, 0, NULL}
#define MALLOC_CHECK_DEC()   (MALLOC_CHECK_STORE.mem_fail_num && !--MALLOC_CHECK_STORE.mem_fail_num)
#define MALLOC_CHECK_FAIL_IN(x)   MALLOC_CHECK_STORE.mem_fail_num = (x)
#define MALLOC_CHECK_SCRUB_PTR(x, y)   memset(x, 0xa5, y)
#define MALLOC_CHECK_PRINT   1
#define MALLOC_CHECK_TRACE   0
#define MALLOC_CHECK_SWAP_TYPE(x, y, type)

Functions

static void malloc_check_alloc (const char *, unsigned int, const char *)
static unsigned int malloc_check_mem (const void *, const char *, unsigned int, const char *)
static unsigned int malloc_check_mem_sz (const void *, size_t, const char *, unsigned int, const char *)
static unsigned int malloc_check_mem_minsz (const void *, size_t, const char *, unsigned int, const char *)
static void * malloc_check_malloc (size_t, const char *, unsigned int, const char *)
static void * malloc_check_calloc (size_t, size_t, const char *, unsigned int, const char *)
static void malloc_check_free (void *, const char *, unsigned int, const char *)
static void * malloc_check_realloc (void *, size_t, const char *, unsigned int, const char *)
static void malloc_check_empty (const char *, unsigned int, const char *)

Variables

Malloc_check_store malloc_check__app_store


Define Documentation

 
#define MALLOC_CHECK__ATTR_H (  ) 

Definition at line 16 of file malloc-check.h.

 
#define MALLOC_CHECK__ATTR_MALLOC (  ) 

Definition at line 24 of file malloc-check.h.

 
#define MALLOC_CHECK__ATTR_USED (  ) 

Definition at line 8 of file malloc-check.h.

#define MALLOC_CHECK_API_F_SCRUB   0

Definition at line 33 of file malloc-check.h.

Referenced by malloc_check_free().

#define MALLOC_CHECK_API_M_SCRUB   0

Definition at line 29 of file malloc-check.h.

Referenced by malloc_check_malloc().

#define MALLOC_CHECK_API_R_SCRUB   0

Definition at line 37 of file malloc-check.h.

Referenced by malloc_check_realloc().

#define MALLOC_CHECK_ASSERT (  ) 

Value:

do {                                     \
      if (x) {} else {                                                  \
        fprintf(stderr, " -=> MC_ASSERT (%s) failed, caller=%s:%s:%d.\n", \
                #x , func, file, line);                                 \
        abort(); }                                                      \
    } while (0)

Definition at line 146 of file malloc-check.h.

Referenced by malloc_check_malloc(), and malloc_check_realloc().

#define malloc_check_assert (  ) 

Value:

do {                                     \
      if (x) {} else {                                                  \
        fprintf(stderr, " -=> mc_assert (%s) failed, caller=%s:%s:%d.\n", \
                #x , func, file, line);                                 \
        abort(); }                                                      \
    } while (0)

Definition at line 140 of file malloc-check.h.

Referenced by malloc_check_alloc(), malloc_check_empty(), malloc_check_free(), malloc_check_mem(), malloc_check_mem_minsz(), and malloc_check_mem_sz().

 
#define MALLOC_CHECK_DEC (  )     (MALLOC_CHECK_STORE.mem_fail_num && !--MALLOC_CHECK_STORE.mem_fail_num)

Definition at line 161 of file malloc-check.h.

Referenced by malloc_check_malloc(), and malloc_check_realloc().

 
#define MALLOC_CHECK_DECL (  )     Malloc_check_store MALLOC_CHECK_STORE = {0, 0, 0, NULL}

Definition at line 154 of file malloc-check.h.

 
#define MALLOC_CHECK_EMPTY (  )     malloc_check_empty(__FILE__, __LINE__, MALLOC_CHECK_FUNC_NAME)

Definition at line 76 of file malloc-check.h.

#define MALLOC_CHECK_FAIL_IN (  )     MALLOC_CHECK_STORE.mem_fail_num = (x)

Definition at line 163 of file malloc-check.h.

#define MALLOC_CHECK_FUNC_NAME   ""

Definition at line 66 of file malloc-check.h.

#define MALLOC_CHECK_H   1

Definition at line 2 of file malloc-check.h.

 
#define MALLOC_CHECK_INIT (  ) 

Value:

Definition at line 49 of file malloc-check.h.

#define MALLOC_CHECK_MEM (  )     malloc_check_mem(x, __FILE__, __LINE__, MALLOC_CHECK_FUNC_NAME)

Definition at line 70 of file malloc-check.h.

#define MALLOC_CHECK_MEM_MINSZ ( x,
 )     malloc_check_mem_minsz(x, y, __FILE__, __LINE__, MALLOC_CHECK_FUNC_NAME)

Definition at line 74 of file malloc-check.h.

#define MALLOC_CHECK_MEM_SZ ( x,
 )     malloc_check_mem_sz(x, y, __FILE__, __LINE__, MALLOC_CHECK_FUNC_NAME)

Definition at line 72 of file malloc-check.h.

#define MALLOC_CHECK_PRINT   1

Definition at line 167 of file malloc-check.h.

Referenced by malloc_check_empty().

 
#define MALLOC_CHECK_REINIT (  ) 

Value:

MALLOC_CHECK_STORE.mem_sz = 0;                   \
    MALLOC_CHECK_STORE.mem_num = 0;                  \
    MALLOC_CHECK_STORE.mem_vals = NULL

Definition at line 45 of file malloc-check.h.

#define MALLOC_CHECK_SCOPE_EXTERN   1

Definition at line 130 of file malloc-check.h.

#define MALLOC_CHECK_SCRUB_PTR ( x,
 )     memset(x, 0xa5, y)

Definition at line 164 of file malloc-check.h.

Referenced by malloc_check_free(), and malloc_check_malloc().

#define MALLOC_CHECK_STORE   malloc_check__app_store

Definition at line 41 of file malloc-check.h.

#define MALLOC_CHECK_SWAP_TYPE ( x,
y,
type   ) 

Value:

do {              \
      type internal_local_tmp = (x);            \
      (x) = (y);                                \
      (y) = internal_local_tmp;                 \
    } while (0)

Definition at line 175 of file malloc-check.h.

Referenced by malloc_check_free().

#define MALLOC_CHECK_TRACE   0

Definition at line 171 of file malloc-check.h.

Referenced by malloc_check_free(), malloc_check_malloc(), and malloc_check_realloc().

#define MC_CALLOC ( x,
 )     malloc_check_calloc(x, y, __FILE__, __LINE__, MALLOC_CHECK_FUNC_NAME)

Definition at line 82 of file malloc-check.h.

#define MC_FREE (  )     malloc_check_free(x, __FILE__, __LINE__, MALLOC_CHECK_FUNC_NAME)

Definition at line 86 of file malloc-check.h.

#define MC_MALLOC (  )     malloc_check_malloc(x, __FILE__, __LINE__, MALLOC_CHECK_FUNC_NAME)

Definition at line 80 of file malloc-check.h.

#define MC_REALLOC ( x,
 )     malloc_check_realloc(x, y, __FILE__, __LINE__, MALLOC_CHECK_FUNC_NAME)

Definition at line 84 of file malloc-check.h.

#define USE_MALLOC_CHECK   1

Definition at line 55 of file malloc-check.h.


Function Documentation

static void malloc_check_alloc ( const char *  file,
unsigned int  line,
const char *  func 
) [static]

Definition at line 203 of file malloc-check.h.

References malloc_check_assert.

Referenced by malloc_check_malloc().

static void * malloc_check_calloc ( size_t  num,
size_t  sz,
const char *  file,
unsigned int  line,
const char *  func 
) [static]

Definition at line 297 of file malloc-check.h.

References malloc_check_malloc().

static void malloc_check_empty ( const char *  file,
unsigned int  line,
const char *  func 
) [static]

Definition at line 395 of file malloc-check.h.

References malloc_check_assert, and MALLOC_CHECK_PRINT.

static void malloc_check_free ( void *  ptr,
const char *  file,
unsigned int  line,
const char *  func 
) [static]

static void * malloc_check_malloc ( size_t  sz,
const char *  file,
unsigned int  line,
const char *  func 
) [static]

static unsigned int malloc_check_mem ( const void *  ptr,
const char *  file,
unsigned int  line,
const char *  func 
) [static]

static unsigned int malloc_check_mem_minsz ( const void *  ptr,
size_t  sz,
const char *  file,
unsigned int  line,
const char *  func 
) [static]

Definition at line 254 of file malloc-check.h.

References malloc_check_assert, and malloc_check_mem().

static unsigned int malloc_check_mem_sz ( const void *  ptr,
size_t  sz,
const char *  file,
unsigned int  line,
const char *  func 
) [static]

Definition at line 243 of file malloc-check.h.

References malloc_check_assert, and malloc_check_mem().

static void * malloc_check_realloc ( void *  ptr,
size_t  sz,
const char *  file,
unsigned int  line,
const char *  func 
) [static]


Variable Documentation


Generated on Tue Jun 30 15:50:44 2009 for rpm by  doxygen 1.5.8