libonion
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
low.c File Reference
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include "low.h"
#include "log.h"

Macros

#define MEMORY_FAILURE(Fmt,...)

Functions

void * onion_low_malloc (size_t sz)
 NEVER FAILING MEMORY ALLOCATORS.
void * onion_low_scalar_malloc (size_t sz)
 Our malloc wrapper for scalar data which does not contain any pointers inside.Knowing that a given zone does not contain any pointer can be useful, e.g. to Hans Boehm's conservative garbage collector on http://hboehm.info/gc/ using GC_MALLOC_ATOMIC....
void * onion_low_calloc (size_t nmemb, size_t size)
 Our calloc wrapper for any kind of data, even scalar one.
void * onion_low_realloc (void *ptr, size_t size)
 Our realloc wrapper for any kind of data, even scalar one.
char * onion_low_strdup (const char *str)
 Our strdup wrapper.
void * onion_low_try_malloc (size_t sz)
 POSSIBLY FAILING MEMORY ALLOCATORS.
void * onion_low_try_scalar_malloc (size_t sz)
 Our malloc wrapper for scalar data which does not contain any pointers inside. May return NULL on fail.
void * onion_low_try_calloc (size_t nmemb, size_t size)
 Our calloc wrapper for any kind of data, even scalar one. May return NULL on fail.
void * onion_low_try_realloc (void *ptr, size_t size)
 Our realloc wrapper for any kind of data, even scalar one. May return NULL on fail.
char * onion_low_try_strdup (const char *str)
 Our strdup wrapper. May return NULL on fail.
void onion_low_free (void *ptr)
 Our free wrapper for any kind of data, even scalar one.
void onion_low_initialize_memory_allocation (onion_low_malloc_sigt *malloc_pf, onion_low_scalar_malloc_sigt *scalarmalloc_pf, onion_low_calloc_sigt *calloc_pf, onion_low_realloc_sigt *realloc_pf, onion_low_strdup_sigt *strdup_pf, onion_low_free_sigt *free_pf, onion_low_memoryfailure_sigt *memoryfailure_pf)
 Our configurator for memory routines.To be called once before any other onion processing at initialization. All the routines should be explicitly provided.

Macro Definition Documentation

#define MEMORY_FAILURE (   Fmt,
  ... 
)
Value:
do { \
char errmsg[48]; \
memset (errmsg, 0, sizeof(errmsg)); \
snprintf (errmsg, sizeof(errmsg), Fmt, __VA_ARGS__); \
memoryfailure_onion_f (errmsg); \
abort (); } while(0)

Referenced by onion_low_calloc(), onion_low_malloc(), onion_low_realloc(), onion_low_scalar_malloc(), and onion_low_strdup().