|GLib Reference Manual|
#include <glib.h> GAllocator; GAllocator* g_allocator_new (const gchar *name, guint n_preallocs); void g_allocator_free (GAllocator *allocator);
The GAllocator is used as an efficient way to allocate small pieces of memory for use with the GList, GSList and GNode data structures. It uses a GMemChunk so elements are allocated in groups, rather than individually.
To use your own GAllocator, create it with g_allocator_new(). Then use g_list_push_allocator(), g_slist_push_allocator() or g_node_push_allocator() before any code which allocates new GList, GSList or GNode elements respectively. After allocating the new elements, you must use g_list_pop_allocator(), g_slist_pop_allocator() or g_node_pop_allocator() to restore the previous allocators.
typedef struct _GAllocator GAllocator;
The GAllocator struct contains private data. and should only be accessed using the following functions.
GAllocator* g_allocator_new (const gchar *name, guint n_preallocs);
Creates a new GAllocator.
|name :||the name of the GAllocator. This name is used to set the name of the GMemChunk used by the GAllocator, and is only used for debugging.|
|n_preallocs :||the number of elements in each block of memory allocated. Larger blocks mean less calls to g_malloc(), but some memory may be wasted. (GLib uses 128 elements per block by default.) The value must be between 1 and 65535.|
|Returns :||a new GAllocator.|
|<< Caches||GLib Tools >>|