Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

c_allocator.h File Reference

Definition of the allocator function type and declaration of a default function based on malloc. More...

#include <stddef.h>
#include "base/inttypes.h"

Go to the source code of this file.

Typedefs

typedef int32_t *(* allocator_f )(size_t intSize, void *data)
 Allocator function.
typedef void(* deallocator_f )(void *mem, size_t intSize, void *data)
 Deallocator function.

Functions

int32_t * base_malloc (size_t intSize, void *unused)
 Default allocator function based on malloc.
void base_free (void *mem, size_t unused1, void *unused2)
 Default deallocator function based on free.

Variables

allocator_t base_mallocator
 Default allocator type based on malloc.


Detailed Description

Definition of the allocator function type and declaration of a default function based on malloc.

In different places where C libraries need memory management, we want to stay independent from particular needs. A generic allocator function is declared for this purpose.


Typedef Documentation

typedef int32_t*(* allocator_f)(size_t intSize, void *data)
 

Allocator function.

Parameters:
intSize,: size to allocate in ints
data,: custom data for the allocator (ignored for malloc, for example, important for a custom allocator)
Returns:
int32_t[intSize]

typedef void(* deallocator_f)(void *mem, size_t intSize, void *data)
 

Deallocator function.

Parameters:
mem,: memory to deallocate
intSize,: size to deallocate in ints
data,: custom data for the allocator
Precondition:
intSize must correspond to the allocated size, mem != NULL.


Function Documentation

void base_free void *  mem,
size_t  unused1,
void *  unused2
 

Default deallocator function based on free.

Parameters:
mem,: memory to deallocate
unused1,unused2,: unused parameters, only to comply with deallocator_f.

int32_t* base_malloc size_t  intSize,
void *  unused
 

Default allocator function based on malloc.

Parameters:
intSize,: size to allocate in ints
unused,: not used, only to comply with allocator_f
Returns:
int32_t[intSize] allocated by malloc


Variable Documentation

allocator_t base_mallocator
 

Default allocator type based on malloc.


Generated on Fri Jun 30 00:02:30 2006 for Module base by  doxygen 1.4.2