RAVE
rave_alloc.h File Reference

Allocation routines for keeping track on memory. More...

#include <stdlib.h>

Go to the source code of this file.

Macros

#define RAVE_MALLOC(sz)
 malloc
 
#define RAVE_CALLOC(npts, sz)
 calloc
 
#define RAVE_REALLOC(ptr, sz)
 realloc
 
#define RAVE_STRDUP(x)
 strdup
 
#define RAVE_FREE(x)
 Frees the pointer if != NULL.
 

Functions

void * rave_alloc_malloc (const char *filename, int lineno, size_t sz)
 Allocates memory and keeps track on if it is released, overwritten and similar.
 
void * rave_alloc_calloc (const char *filename, int lineno, size_t npts, size_t sz)
 Same as calloc but debugged.
 
void * rave_alloc_realloc (const char *filename, int lineno, void *ptr, size_t sz)
 Same as realloc but debugged.
 
char * rave_alloc_strdup (const char *filename, int lineno, const char *str)
 Same as strdup but debugged.
 
void rave_alloc_free (const char *filename, int lineno, void *ptr)
 Releases the memory.
 
void rave_alloc_dump_heap (void)
 Dumps all blocks that not has been released.
 
void rave_alloc_print_statistics (void)
 Prints the statistics for the heap.
 

Detailed Description

Allocation routines for keeping track on memory.

Author
Anders Henja (Swedish Meteorological and Hydrological Institute, SMHI)
Date
2009-08-15

Macro Definition Documentation

◆ RAVE_CALLOC

#define RAVE_CALLOC ( npts,
sz )
Value:
calloc(npts, sz)

calloc

◆ RAVE_FREE

#define RAVE_FREE ( x)
Value:
if (x != NULL) {free(x);x=NULL;}

Frees the pointer if != NULL.

◆ RAVE_MALLOC

#define RAVE_MALLOC ( sz)
Value:
malloc(sz)

malloc

◆ RAVE_REALLOC

#define RAVE_REALLOC ( ptr,
sz )
Value:
realloc(ptr, sz)

realloc

◆ RAVE_STRDUP

#define RAVE_STRDUP ( x)
Value:
strdup(x)

strdup

Function Documentation

◆ rave_alloc_calloc()

void * rave_alloc_calloc ( const char * filename,
int lineno,
size_t npts,
size_t sz )

Same as calloc but debugged.

Parameters
[in]filenamethe name of the file the allocation occurs in
[in]linenothe linenumber
[in]nptsnumber of points
[in]szthe number of bytes to be allocated

◆ rave_alloc_dump_heap()

void rave_alloc_dump_heap ( void )

Dumps all blocks that not has been released.

◆ rave_alloc_free()

void rave_alloc_free ( const char * filename,
int lineno,
void * ptr )

Releases the memory.

Parameters
[in]filenamethe name of the file the allocation occurs in
[in]linenothe linenumber
[in]ptrthe pointer that should be freed

◆ rave_alloc_malloc()

void * rave_alloc_malloc ( const char * filename,
int lineno,
size_t sz )

Allocates memory and keeps track on if it is released, overwritten and similar.

Parameters
[in]filenamethe name of the file the allocation occurs in
[in]linenothe linenumber
[in]szthe number of bytes to be allocated

◆ rave_alloc_print_statistics()

void rave_alloc_print_statistics ( void )

Prints the statistics for the heap.

◆ rave_alloc_realloc()

void * rave_alloc_realloc ( const char * filename,
int lineno,
void * ptr,
size_t sz )

Same as realloc but debugged.

Parameters
[in]filenamethe name of the file the allocation occurs in
[in]linenothe linenumber
[in]ptrthe original pointer
[in]szthe number of bytes to be allocated

◆ rave_alloc_strdup()

char * rave_alloc_strdup ( const char * filename,
int lineno,
const char * str )

Same as strdup but debugged.

Parameters
[in]filenamethe name of the file the allocation occurs in
[in]linenothe linenumber
[in]strthe number of bytes to be allocated