ELinks 0.16.1.1
memory.h File Reference
#include <sys/types.h>
#include <stddef.h>
#include <string.h>
Include dependency graph for memory.h:

Macros

#define ALLOC_MAXTRIES   3
 Max.
#define ALLOC_DELAY   3
 Delay in seconds between each alloc try.
#define fmem_alloc(x)
#define fmem_free(x)
#define mem_mmap_alloc(x)
 Cygwin wants some size_t definition here... let's try to make it happy then.
#define mem_mmap_free(x, y)
#define mem_mmap_realloc(x, y, z)
#define intdup(i)
Maybe-free macros
Todo
TODO: Think about making what they do more obvious in their identifier, they could be obfuscating their users a little for the newcomers otherwise.
#define mem_free_set(x, v)
#define mem_free_if(x)

Functions

void * mem_alloc (size_t)
void * mem_calloc (size_t, size_t)
void mem_free (void *)
void * mem_realloc (void *, size_t)
static int * intdup__ (int i)

Granular memory allocation.

The granularity used by the aligned memory functions below must be a mask with all bits set from but not including the most significant bit and down.

So if an alignment of 256 is wanted use 0xFF.

#define ALLOC_GR   0x100
 The 'old' style granularity.
#define ALIGN_MEMORY_SIZE(x, gr)
#define mem_align_alloc(ptr, old, new_, mask)
static void * mem_align_alloc__ (void **ptr, size_t old, size_t new_, size_t objsize, size_t mask)

Macro Definition Documentation

◆ ALIGN_MEMORY_SIZE

#define ALIGN_MEMORY_SIZE ( x,
gr )
Value:
(((x) + (gr)) & ~(gr))

◆ ALLOC_DELAY

#define ALLOC_DELAY   3

Delay in seconds between each alloc try.

◆ ALLOC_GR

#define ALLOC_GR   0x100

The 'old' style granularity.

XXX: Must be power of 2

◆ ALLOC_MAXTRIES

#define ALLOC_MAXTRIES   3

Max.

number of retry in case of memory allocation failure.

◆ fmem_alloc

#define fmem_alloc ( x)
Value:
void * mem_alloc(size_t)

◆ fmem_free

#define fmem_free ( x)
Value:
void mem_free(void *)

◆ intdup

#define intdup ( i)
Value:
static int * intdup__(int i)
Definition memory.h:181
i
Definition uni_7b.inc:369

◆ mem_align_alloc

#define mem_align_alloc ( ptr,
old,
new_,
mask )
Value:
mem_align_alloc__((void **) ptr, old, new_, sizeof(**ptr), mask)
static void * mem_align_alloc__(void **ptr, size_t old, size_t new_, size_t objsize, size_t mask)
Definition memory.h:115

◆ mem_free_if

#define mem_free_if ( x)
Value:
do { void *p = (x); if (p) mem_free(p); } while (0)

◆ mem_free_set

#define mem_free_set ( x,
v )
Value:
do { if (*(x)) mem_free(*(x)); *(x) = (v); } while (0)

◆ mem_mmap_alloc

#define mem_mmap_alloc ( x)
Value:

Cygwin wants some size_t definition here... let's try to make it happy then.

Hrmpf.

◆ mem_mmap_free

#define mem_mmap_free ( x,
y )
Value:

◆ mem_mmap_realloc

#define mem_mmap_realloc ( x,
y,
z )
Value:
void * mem_realloc(void *, size_t)

Function Documentation

◆ intdup__()

int * intdup__ ( int i)
inlinestatic

◆ mem_align_alloc__()

void * mem_align_alloc__ ( void ** ptr,
size_t old,
size_t new_,
size_t objsize,
size_t mask )
inlinestatic

◆ mem_alloc()

void * mem_alloc ( size_t )

◆ mem_calloc()

void * mem_calloc ( size_t ,
size_t  )

◆ mem_free()

void mem_free ( void * )

◆ mem_realloc()

void * mem_realloc ( void * ,
size_t  )