glib/docs/reference/glib/tmpl/allocators.sgml
Matthias Clasen 3fa33317b7 Documentation fixes.
* glib/gconvert.c, glib/grand.c, glib/ghash.c,
        glib/gthreadpool.c, glib/gtree.c: Documentation fixes.

        * glib/tmpl/allocators.sgml, glib/tmpl/arrays.sgml,
        glib/tmpl/arrays_byte.sgml, glib/tmpl/arrays_pointer.sgml,
        glib/tmpl/caches.sgml, glib/tmpl/completion.sgml,
        glib/tmpl/conversions.sgml,
        glib/tmpl/datalist.sgml, glib/tmpl/date.sgml,
        glib/tmpl/error_reporting.sgml, glib/tmpl/fileutils.sgml,
        glib/tmpl/hash_tables.sgml,
        glib/tmpl/hooks.sgml, glib/tmpl/macros.sgml,
        glib/tmpl/macros_misc.sgml, glib/tmpl/main.sgml, glib/tmpl/markup.sgml,
        glib/tmpl/memory.sgml, glib/tmpl/memory_chunks.sgml,
        glib/tmpl/messages.sgml, glib/tmpl/misc_utils.sgml,
        glib/tmpl/modules.sgml, glib/tmpl/numerical.sgml,
        glib/tmpl/patterns.sgml, glib/tmpl/queue.sgml,
        glib/tmpl/shell.sgml, glib/tmpl/spawn.sgml,
        glib/tmpl/string_utils.sgml, glib/tmpl/thread_pools.sgml,
        glib/tmpl/threads.sgml, glib/tmpl/timers.sgml,
        glib/tmpl/trees-binary.sgml, glib/tmpl/trees-nary.sgml,
        glib/tmpl/type_conversion.sgml, glib/tmpl/unicode.sgml,
        glib/tmpl/warnings.sgml, glib/tmpl/windows.sgml:
        Improve markup of examples, general consistency improvements.
2001-12-12 20:32:07 +00:00

66 lines
2.0 KiB
Plaintext

<!-- ##### SECTION Title ##### -->
Memory Allocators
<!-- ##### SECTION Short_Description ##### -->
allocates chunks of memory for #GList, #GSList and #GNode.
<!-- ##### SECTION Long_Description ##### -->
<para>
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.
</para>
<para>
The #GList, #GSList and #GNode implementations create default #GAllocator
objects, which are probably sufficient for most purposes. These default
allocators use blocks of 128 elements.
</para>
<para>
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.
</para>
<para>
Note that you cannot use the same allocator for #GList, #GSList and #GNode
elements. Each must use separate allocators.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### STRUCT GAllocator ##### -->
<para>
The <structname>GAllocator</structname> struct contains private data. and should only be accessed
using the following functions.
</para>
<!-- ##### FUNCTION g_allocator_new ##### -->
<para>
Creates a new #GAllocator.
</para>
@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.
<!-- ##### FUNCTION g_allocator_free ##### -->
<para>
Frees all of the memory allocated by the #GAllocator.
</para>
@allocator: a #GAllocator.