cb0863ca9e70ea9f6ba89f9416c3e46e7fd0aeb2
[platform/upstream/glib2.0.git] / docs / reference / glib / html / glib-Memory-Allocators.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>Memory Allocators</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
7 <link rel="home" href="index.html" title="GLib Reference Manual">
8 <link rel="up" href="glib-data-types.html" title="GLib Data Types">
9 <link rel="prev" href="glib-Caches.html" title="Caches">
10 <link rel="next" href="glib-GVariantType.html" title="GVariantType">
11 <meta name="generator" content="GTK-Doc V1.13 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
13 <link rel="chapter" href="glib.html" title="GLib Overview">
14 <link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals">
15 <link rel="chapter" href="glib-core.html" title="GLib Core Application Support">
16 <link rel="chapter" href="glib-utilities.html" title="GLib Utilities">
17 <link rel="chapter" href="glib-data-types.html" title="GLib Data Types">
18 <link rel="chapter" href="tools.html" title="GLib Tools">
19 <link rel="index" href="api-index-full.html" title="Index">
20 <link rel="index" href="api-index-deprecated.html" title="Index of deprecated symbols">
21 <link rel="index" href="api-index-2-2.html" title="Index of new symbols in 2.2">
22 <link rel="index" href="api-index-2-4.html" title="Index of new symbols in 2.4">
23 <link rel="index" href="api-index-2-6.html" title="Index of new symbols in 2.6">
24 <link rel="index" href="api-index-2-8.html" title="Index of new symbols in 2.8">
25 <link rel="index" href="api-index-2-10.html" title="Index of new symbols in 2.10">
26 <link rel="index" href="api-index-2-12.html" title="Index of new symbols in 2.12">
27 <link rel="index" href="api-index-2-14.html" title="Index of new symbols in 2.14">
28 <link rel="index" href="api-index-2-16.html" title="Index of new symbols in 2.16">
29 <link rel="index" href="api-index-2-18.html" title="Index of new symbols in 2.18">
30 <link rel="index" href="api-index-2-20.html" title="Index of new symbols in 2.20">
31 <link rel="index" href="api-index-2-22.html" title="Index of new symbols in 2.22">
32 <link rel="index" href="api-index-2-24.html" title="Index of new symbols in 2.24">
33 </head>
34 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
35 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
36 <tr valign="middle">
37 <td><a accesskey="p" href="glib-Caches.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
38 <td><a accesskey="u" href="glib-data-types.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
39 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
40 <th width="100%" align="center">GLib Reference Manual</th>
41 <td><a accesskey="n" href="glib-GVariantType.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
42 </tr>
43 <tr><td colspan="5" class="shortcuts">
44 <a href="#glib-Memory-Allocators.synopsis" class="shortcut">Top</a>
45                    | 
46                   <a href="#glib-Memory-Allocators.description" class="shortcut">Description</a>
47 </td></tr>
48 </table>
49 <div class="refentry" title="Memory Allocators">
50 <a name="glib-Memory-Allocators"></a><div class="titlepage"></div>
51 <div class="refnamediv"><table width="100%"><tr>
52 <td valign="top">
53 <h2><span class="refentrytitle"><a name="glib-Memory-Allocators.top_of_page"></a>Memory Allocators</span></h2>
54 <p>Memory Allocators — deprecated way to allocate chunks of memory for
55                     GList, GSList and GNode</p>
56 </td>
57 <td valign="top" align="right"></td>
58 </tr></table></div>
59 <div class="refsynopsisdiv" title="Synopsis">
60 <a name="glib-Memory-Allocators.synopsis"></a><h2>Synopsis</h2>
61 <pre class="synopsis">
62 #include &lt;glib.h&gt;
63
64                     <a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator">GAllocator</a>;
65 <a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator"><span class="returnvalue">GAllocator</span></a>*         <a class="link" href="glib-Memory-Allocators.html#g-allocator-new" title="g_allocator_new ()">g_allocator_new</a>                     (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *name,
66                                                          <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a> n_preallocs);
67 <span class="returnvalue">void</span>                <a class="link" href="glib-Memory-Allocators.html#g-allocator-free" title="g_allocator_free ()">g_allocator_free</a>                    (<a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator"><span class="returnvalue">GAllocator</span></a> *allocator);
68 </pre>
69 </div>
70 <div class="refsect1" title="Description">
71 <a name="glib-Memory-Allocators.description"></a><h2>Description</h2>
72 <p>
73 Prior to 2.10, <a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator"><span class="type">GAllocator</span></a> was used as an efficient way to allocate
74 small pieces of memory for use with the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="GList"><span class="type">GList</span></a>, <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="GSList"><span class="type">GSList</span></a> and <a class="link" href="glib-N-ary-Trees.html#GNode" title="GNode"><span class="type">GNode</span></a>
75 data structures. Since 2.10, it has been completely replaced by the
76 <a class="link" href="glib-Memory-Slices.html" title="Memory Slices">slice allocator</a> and
77 deprecated.</p>
78 </div>
79 <div class="refsect1" title="Details">
80 <a name="glib-Memory-Allocators.details"></a><h2>Details</h2>
81 <div class="refsect2" title="GAllocator">
82 <a name="GAllocator"></a><h3>GAllocator</h3>
83 <pre class="programlisting">typedef struct _GAllocator GAllocator;</pre>
84 <div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;">
85 <h3 class="title">Warning</h3>
86 <p><code class="literal">GAllocator</code> is deprecated and should not be used in newly-written code.</p>
87 </div>
88 <p>
89 The <a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator"><span class="type">GAllocator</span></a> struct contains private data. and should only be
90 accessed using the following functions.</p>
91 </div>
92 <hr>
93 <div class="refsect2" title="g_allocator_new ()">
94 <a name="g-allocator-new"></a><h3>g_allocator_new ()</h3>
95 <pre class="programlisting"><a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator"><span class="returnvalue">GAllocator</span></a>*         g_allocator_new                     (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *name,
96                                                          <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a> n_preallocs);</pre>
97 <div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;">
98 <h3 class="title">Warning</h3>
99 <p><code class="literal">g_allocator_new</code> has been deprecated since version 2.10 and should not be used in newly-written code. Use the <a class="link" href="glib-Memory-Slices.html" title="Memory Slices">slice
100                  allocator</a> instead</p>
101 </div>
102 <p>
103 Creates a new <a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator"><span class="type">GAllocator</span></a>.</p>
104 <div class="variablelist"><table border="0">
105 <col align="left" valign="top">
106 <tbody>
107 <tr>
108 <td><p><span class="term"><em class="parameter"><code>name</code></em> :</span></p></td>
109 <td> the name of the <a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator"><span class="type">GAllocator</span></a>. This name is used to set the
110        name of the <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a> used by the <a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator"><span class="type">GAllocator</span></a>, and is only
111        used for debugging.
112 </td>
113 </tr>
114 <tr>
115 <td><p><span class="term"><em class="parameter"><code>n_preallocs</code></em> :</span></p></td>
116 <td> the number of elements in each block of memory
117               allocated.  Larger blocks mean less calls to
118               <a class="link" href="glib-Memory-Allocation.html#g-malloc" title="g_malloc ()"><code class="function">g_malloc()</code></a>, but some memory may be wasted.  (GLib uses
119               128 elements per block by default.) The value must be
120               between 1 and 65535.
121 </td>
122 </tr>
123 <tr>
124 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
125 <td> a new <a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator"><span class="type">GAllocator</span></a>.
126 </td>
127 </tr>
128 </tbody>
129 </table></div>
130 </div>
131 <hr>
132 <div class="refsect2" title="g_allocator_free ()">
133 <a name="g-allocator-free"></a><h3>g_allocator_free ()</h3>
134 <pre class="programlisting"><span class="returnvalue">void</span>                g_allocator_free                    (<a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator"><span class="returnvalue">GAllocator</span></a> *allocator);</pre>
135 <div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;">
136 <h3 class="title">Warning</h3>
137 <p><code class="literal">g_allocator_free</code> has been deprecated since version 2.10 and should not be used in newly-written code. Use the <a class="link" href="glib-Memory-Slices.html" title="Memory Slices">slice
138                  allocator</a> instead</p>
139 </div>
140 <p>
141 Frees all of the memory allocated by the <a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator"><span class="type">GAllocator</span></a>.</p>
142 <div class="variablelist"><table border="0">
143 <col align="left" valign="top">
144 <tbody><tr>
145 <td><p><span class="term"><em class="parameter"><code>allocator</code></em> :</span></p></td>
146 <td> a <a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator"><span class="type">GAllocator</span></a>.
147 </td>
148 </tr></tbody>
149 </table></div>
150 </div>
151 </div>
152 </div>
153 <div class="footer">
154 <hr>
155           Generated by GTK-Doc V1.13</div>
156 </body>
157 </html>