Memory management

Memory management — Memory management

Synopsis




void*               kit_malloc                          (size_t bytes);
void*               kit_malloc0                         (size_t bytes);
void*               kit_realloc                         (void *memory,
                                                         size_t bytes);
void                kit_free                            (void *memory);
#define             kit_new                             (type, count)
#define             kit_new0                            (type, count)

Description

Functions used for memory management.

Details

kit_malloc ()

void*               kit_malloc                          (size_t bytes);

Allocate memory

bytes :

number of 8-bit bytes to allocate

Returns :

memory location or NULL on OOM. Free with kit_free().

kit_malloc0 ()

void*               kit_malloc0                         (size_t bytes);

Allocate memory and zero it.

bytes :

number of 8-bit bytes to allocate

Returns :

memory location or NULL on OOM. Free with kit_free().

kit_realloc ()

void*               kit_realloc                         (void *memory,
                                                         size_t bytes);

Reallocate memory; like realloc(3).

memory :

memory previously allocated

bytes :

new size

Returns :

memory location or NULL on OOM. Free with kit_free().

kit_free ()

void                kit_free                            (void *memory);

Free memory allocated by kit_malloc() + friends.

memory :

pointer to memory allocated with kit_malloc() + friends

kit_new()

#define kit_new(type, count)  ((type*)kit_malloc (sizeof (type) * (count)));

Allocate memory for count structures of type type.

type :

the type of object to allocate

count :

number of objects to allocate

kit_new0()

#define kit_new0(type, count) ((type*)kit_malloc0 (sizeof (type) * (count)));

Allocate zeroed memory for count structures of type type.

type :

the type of object to allocate

count :

number of objects to allocate