GRU - Generic Reusable Utilities
Macros | Functions
gru_alloc.h File Reference
#include "gru_base.h"
#include "gru_status.h"

Go to the source code of this file.

Macros

#define gru_alloc_check(obj, ret)
 Check whether the allocation was successful otherwise return whatever set as ret. More...
 

Functions

gru_export void * gru_alloc (size_t size, gru_status_t *status)
 Allocate a block of memory. More...
 
gru_export void gru_dealloc (void **obj)
 Deallocate a block of memory and set its pointer to NULL. More...
 
gru_export void gru_dealloc_string (char **obj)
 Deallocate a block of memory used by a char * and set its pointer to NULL. More...
 
gru_export void gru_dealloc_const_string (const char **obj)
 Deallocate a block of memory used by a const char * and set its pointer to NULL. More...
 

Macro Definition Documentation

◆ gru_alloc_check

#define gru_alloc_check (   obj,
  ret 
)
Value:
if ((obj) == NULL) \
return ret;

Check whether the allocation was successful otherwise return whatever set as ret.

Function Documentation

◆ gru_alloc()

gru_export void* gru_alloc ( size_t  size,
gru_status_t status 
)

Allocate a block of memory.

Parameters
sizethe amount of memory (in bytes) to allocate
statusa status pointer that will be set in case of failure
Returns
a pointer to the newly allocated memory or NULL if failed

◆ gru_dealloc()

gru_export void gru_dealloc ( void **  obj)

Deallocate a block of memory and set its pointer to NULL.

Parameters
obja pointer to a pointer of block of memory to deallocate

◆ gru_dealloc_const_string()

gru_export void gru_dealloc_const_string ( const char **  obj)
inline

Deallocate a block of memory used by a const char * and set its pointer to NULL.

Parameters
obja pointer to a pointer of block of memory to deallocate

◆ gru_dealloc_string()

gru_export void gru_dealloc_string ( char **  obj)
inline

Deallocate a block of memory used by a char * and set its pointer to NULL.

Parameters
obja pointer to a pointer of block of memory to deallocate