<refentry id="glib-Memory-Allocators">
<refmeta>
<refentrytitle role="top_of_page" id="glib-Memory-Allocators.top_of_page">Memory Allocators</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GLIB Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>Memory Allocators</refname>
<refpurpose>deprecated way to allocate chunks of memory for GList, GSList and GNode</refpurpose>
</refnamediv>

<refsynopsisdiv id="glib-Memory-Allocators.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>

#include &lt;glib.h&gt;

                    <link linkend="GAllocator">GAllocator</link>;
<link linkend="GAllocator">GAllocator</link>*         <link linkend="g-allocator-new">g_allocator_new</link>                     (const <link linkend="gchar">gchar</link> *name,
                                                         <link linkend="guint">guint</link> n_preallocs);
<link linkend="void">void</link>                <link linkend="g-allocator-free">g_allocator_free</link>                    (<link linkend="GAllocator">GAllocator</link> *allocator);
</synopsis>
</refsynopsisdiv>









<refsect1 id="glib-Memory-Allocators.description" role="desc">
<title role="desc.title">Description</title>
<para>
</para>
<para>
Prior to 2.10, <link linkend="GAllocator"><type>GAllocator</type></link> was used as an efficient way to allocate
small pieces of memory for use with the <link linkend="GList"><type>GList</type></link>, <link linkend="GSList"><type>GSList</type></link> and <link linkend="GNode"><type>GNode</type></link> data
structures. Since 2.10, it has been completely replaced by the
<link linkend="glib-Memory-Slices">slice allocator</link> and deprecated.
</para>
</refsect1>

<refsect1 id="glib-Memory-Allocators.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="GAllocator" role="struct" condition="deprecated:">
<title>GAllocator</title>
<indexterm zone="GAllocator" role="deprecated"><primary sortas="Allocator">GAllocator</primary></indexterm><programlisting>typedef struct _GAllocator GAllocator;</programlisting>
<warning><para><literal>GAllocator</literal> is deprecated and should not be used in newly-written code.</para></warning>
<para>
The <structname>GAllocator</structname> struct contains private data. and
should only be accessed using the following functions.
</para></refsect2>
<refsect2 id="g-allocator-new" role="function" condition="deprecated">
<title>g_allocator_new ()</title>
<indexterm zone="g-allocator-new" role="deprecated"><primary sortas="allocator_new">g_allocator_new</primary></indexterm><programlisting><link linkend="GAllocator">GAllocator</link>*         g_allocator_new                     (const <link linkend="gchar">gchar</link> *name,
                                                         <link linkend="guint">guint</link> n_preallocs);</programlisting>
<warning><para><literal>g_allocator_new</literal> has been deprecated since version 2.10 and should not be used in newly-written code. Use the <link linkend="glib-Memory-Slices">slice allocator</link>
instead</para></warning>
<para>
Creates a new <link linkend="GAllocator"><type>GAllocator</type></link>.
</para><variablelist role="params">
<varlistentry><term><parameter>name</parameter>&#160;:</term>
<listitem><simpara>the name of the <link linkend="GAllocator"><type>GAllocator</type></link>. This name is used to set the name of the
<link linkend="GMemChunk"><type>GMemChunk</type></link> used by the <link linkend="GAllocator"><type>GAllocator</type></link>, and is only used for debugging.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>n_preallocs</parameter>&#160;:</term>
<listitem><simpara>the number of elements in each block of memory allocated.
Larger blocks mean less calls to <link linkend="g-malloc"><function>g_malloc()</function></link>, but some memory may be wasted.
(GLib uses 128 elements per block by default.) The value must be between 1
and 65535.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>a new <link linkend="GAllocator"><type>GAllocator</type></link>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-allocator-free" role="function" condition="deprecated">
<title>g_allocator_free ()</title>
<indexterm zone="g-allocator-free" role="deprecated"><primary sortas="allocator_free">g_allocator_free</primary></indexterm><programlisting><link linkend="void">void</link>                g_allocator_free                    (<link linkend="GAllocator">GAllocator</link> *allocator);</programlisting>
<warning><para><literal>g_allocator_free</literal> has been deprecated since version 2.10 and should not be used in newly-written code. Use the <link linkend="glib-Memory-Slices">slice allocator</link>
instead</para></warning>
<para>
Frees all of the memory allocated by the <link linkend="GAllocator"><type>GAllocator</type></link>.
</para><variablelist role="params">
<varlistentry><term><parameter>allocator</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GAllocator"><type>GAllocator</type></link>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>

</refsect1>




</refentry>
