NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.52">

Memory Management


Memory Management -- Memory Management API for libart users.


#define     art_alloc
#define     art_free
#define     art_realloc
#define     art_new                         (type, n)
#define     art_renew                       (p, type, n)


These API functions are a set of wrapper functions around the OS-specific memory management functions: they are used to keep the user-level code portable. Their definitions are straighforward so we will not get into any details. XXX: check for g_new behaviour when memory allocation problem.



#define art_alloc malloc

Same semantics as those of the standard C malloc function.


#define art_free free

Same semantics as those of the standard C free function.


#define art_realloc realloc

Same semantics as those of the standard C realloc function.


#define art_new(type, n) ((type *)art_alloc ((n) * sizeof(type)))

This macro is not equivalent to the glib g_new function. As g_new, it takes two parameters: the type of the object to instantiate as first parameter and the number of such objects to instantiate as second parameter. It will return a dynamically allocated array of memory you can use to store objects in. In case of failure of the memory allocation, it will return NULL (this is very diffrent from g_new which does not return in case of failure. g_new allways suceeds).

type :the type of the object to instantiate.
n :number of objects to instantiate.


#define art_renew(p, type, n) ((type *)art_realloc (p, (n) * sizeof(type)))

This macro allows you to reallocate a dynamically allocated array of objects. As with realloc and malloc, if p is NULL, this is equivalent to art_new.

p :the object array to renew.
type :the type of the objects.
n :the new number of objects you want in the array.