cu/scratch.h: Scratch Memory for Repeated Reuse
[Utilities]

Data Structures

struct  cu_scratch

Defines

#define CU_SCRATCH_INIT   { 0, NULL }
#define cu_scratch_cct   cu_scratch_init

Typedefs

typedef struct cu_scratchcu_scratch_t

Functions

void cu_scratch_init (cu_scratch_t scr)
size_t cu_scratch_size (cu_scratch_t scr)
void * cu_scratch_ptr (cu_scratch_t scr)
void cuP_scratch_alloc_min (cu_scratch_t, size_t)
void cuP_scratch_alloc_log (cu_scratch_t, size_t)
void cuP_scratch_realloc_min (cu_scratch_t, size_t)
void cuP_scratch_realloc_log (cu_scratch_t, size_t)
void * cu_scratch_alloc_min (cu_scratch_t scr, size_t size)
void * cu_scratch_alloc_log (cu_scratch_t scr, size_t size)
void * cu_scratch_realloc_min (cu_scratch_t scr, size_t size)
void * cu_scratch_realloc_log (cu_scratch_t scr, size_t size)

Detailed Description

This header defines a small object to manage reuse of a scratch memory area. It is mainly inteded to be defined in function bodies and used in inner loops when cu_salloc is not feasible.


Define Documentation

#define cu_scratch_cct   cu_scratch_init
#define CU_SCRATCH_INIT   { 0, NULL }

An initialiser which can be assigned in a declaration of a variable of type struct cu_scratch.


Function Documentation

void* cu_scratch_alloc_log ( cu_scratch_t  scr,
size_t  size 
)

Extend scr to the maximum of size and twice the old size, unless the old size is at least size, and return a pointer to it's memory. Does not preserve the contents.

void* cu_scratch_alloc_min ( cu_scratch_t  scr,
size_t  size 
)

Extend scr to size unless it already is at least that big, and return a pointer to it's memory. Does not preserve the contents.

void cu_scratch_init ( cu_scratch_t  scr  ) 

Alternative to CU_SCRATCH_INIT.

void* cu_scratch_ptr ( cu_scratch_t  scr  ) 

A pointer to the start of the scratch memory.

void* cu_scratch_realloc_log ( cu_scratch_t  scr,
size_t  size 
)

As cu_scratch_alloc_log, but preserves content.

void* cu_scratch_realloc_min ( cu_scratch_t  scr,
size_t  size 
)

As cu_scratch_alloc_min, but preseves content.

size_t cu_scratch_size ( cu_scratch_t  scr  ) 

The size of scr.

Generated 2009-11-23 for culibs-0.25 using Doxygen. Maintained by Petter Urkedal.