📄 allocators.sgml
字号:
<!-- ##### 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 ofmemory for use with the #GList, #GSList and #GNode data structures.It uses a #GMemChunk so elements are allocated in groups, rather thanindividually.</para><para>The #GList, #GSList and #GNode implementations create default #GAllocatorobjects, which are probably sufficient for most purposes. These defaultallocators use blocks of 128 elements.</para><para>To use your own #GAllocator, create it with g_allocator_new(). Thenuse g_list_push_allocator(), g_slist_push_allocator() org_node_push_allocator() before any code which allocates new #GList, #GSListor #GNode elements respectively. After allocating the new elements, you mustuse 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 #GNodeelements. 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 accessedusing 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 1and 65535.@Returns: a new #GAllocator.<!-- ##### FUNCTION g_allocator_free ##### --><para>Frees all of the memory allocated by the #GAllocator.</para>@allocator: a #GAllocator.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -