Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
memalloc.h File Reference
#include <Inventor/C/basic.h>
#include <stdarg.h>

Go to the source code of this file.

Typedefs

typedef struct cc_memalloc cc_memalloc
 
typedef int cc_memalloc_strategy_cb(const int numunits_allocated)
 

Functions

cc_memalloccc_memalloc_construct (const unsigned int unitsize)
 
void cc_memalloc_destruct (cc_memalloc *allocator)
 
void * cc_memalloc_allocate (cc_memalloc *allocator)
 
void cc_memalloc_deallocate (cc_memalloc *allocator, void *ptr)
 
void cc_memalloc_clear (cc_memalloc *allocator)
 
void cc_memalloc_set_strategy (cc_memalloc *allocator, cc_memalloc_strategy_cb *cb)
 

Typedef Documentation

◆ cc_memalloc

struct cc_memalloc cc_memalloc

A type definition for the memory allocator structure.

◆ cc_memalloc_strategy_cb

int cc_memalloc_strategy_cb

The type definition for the memory allocator strategy callback function.

Function Documentation

◆ cc_memalloc_construct()

cc_memalloc* cc_memalloc_construct ( const unsigned int  unitsize)

Construct a memory allocator. Each allocated unit will be unitsize bytes.

◆ cc_memalloc_destruct()

void cc_memalloc_destruct ( cc_memalloc allocator)

Destruct allocator, freeing all memory used.

◆ cc_memalloc_allocate()

void* cc_memalloc_allocate ( cc_memalloc allocator)

Allocate a memory unit from allocator.

◆ cc_memalloc_deallocate()

void cc_memalloc_deallocate ( cc_memalloc allocator,
void *  ptr 
)

Deallocate a memory unit. ptr must have been allocated using cc_memalloc_allocate(), of course.

◆ cc_memalloc_clear()

void cc_memalloc_clear ( cc_memalloc allocator)

Free all memory allocated by allocator.

◆ cc_memalloc_set_strategy()

void cc_memalloc_set_strategy ( cc_memalloc allocator,
cc_memalloc_strategy_cb cb 
)

Sets the allocator strategy callback. cb should be a function that returns the number of units to allocated in a block, based on the number of units currently allocated.

The default strategy is to just return the number of units allocated (which will successively double the internal memory chunk sizes), unless the number of units allocated is less than 64, then 64 is returned.