~ubuntu-branches/ubuntu/utopic/glib2.0/utopic

« back to all changes in this revision

Viewing changes to docs/reference/glib/html/glib-Memory-Allocators.html

Tags: upstream-2.12.12
ImportĀ upstreamĀ versionĀ 2.12.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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=US-ASCII">
 
5
<title>Memory Allocators</title>
 
6
<meta name="generator" content="DocBook XSL Stylesheets V1.72.0">
 
7
<link rel="start" 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="tools.html" title="GLib Tools">
 
11
<meta name="generator" content="GTK-Doc V1.7 (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="ix01.html" title="Index">
 
20
<link rel="index" href="ix02.html" title="Index of deprecated symbols">
 
21
<link rel="index" href="ix03.html" title="Index of new symbols in 2.2">
 
22
<link rel="index" href="ix04.html" title="Index of new symbols in 2.4">
 
23
<link rel="index" href="ix05.html" title="Index of new symbols in 2.6">
 
24
<link rel="index" href="ix06.html" title="Index of new symbols in 2.8">
 
25
<link rel="index" href="ix07.html" title="Index of new symbols in 2.10">
 
26
<link rel="index" href="ix08.html" title="Index of new symbols in 2.12">
 
27
</head>
 
28
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
 
29
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
 
30
<tr valign="middle">
 
31
<td><a accesskey="p" href="glib-Caches.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
 
32
<td><a accesskey="u" href="glib-data-types.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
 
33
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
 
34
<th width="100%" align="center">GLib Reference Manual</th>
 
35
<td><a accesskey="n" href="tools.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
 
36
</tr>
 
37
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id3155822" class="shortcut">Top</a>
 
38
                  &#160;|&#160;
 
39
                  <a href="#id3155920" class="shortcut">Description</a></nobr></td></tr>
 
40
</table>
 
41
<div class="refentry" lang="en">
 
42
<a name="glib-Memory-Allocators"></a><div class="titlepage"></div>
 
43
<div class="refnamediv"><table width="100%"><tr>
 
44
<td valign="top">
 
45
<h2>
 
46
<a name="id3155822"></a><span class="refentrytitle">Memory Allocators</span>
 
47
</h2>
 
48
<p>Memory Allocators &#8212; deprecated way to allocate chunks of memory for <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>, <a href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> and <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>.</p>
 
49
</td>
 
50
<td valign="top" align="right"></td>
 
51
</tr></table></div>
 
52
<div class="refsynopsisdiv">
 
53
<h2>Synopsis</h2>
 
54
<pre class="synopsis">
 
55
 
 
56
#include &lt;glib.h&gt;
 
57
 
 
58
 
 
59
                    <a href="glib-Memory-Allocators.html#GAllocator">GAllocator</a>;
 
60
<a href="glib-Memory-Allocators.html#GAllocator">GAllocator</a>*         <a href="glib-Memory-Allocators.html#g-allocator-new">g_allocator_new</a>                     (const <a href="glib-Basic-Types.html#gchar">gchar</a> *name,
 
61
                                                         <a href="glib-Basic-Types.html#guint">guint</a> n_preallocs);
 
62
void                <a href="glib-Memory-Allocators.html#g-allocator-free">g_allocator_free</a>                    (<a href="glib-Memory-Allocators.html#GAllocator">GAllocator</a> *allocator);
 
63
 
 
64
</pre>
 
65
</div>
 
66
<div class="refsect1" lang="en">
 
67
<a name="id3155920"></a><h2>Description</h2>
 
68
<p>
 
69
</p>
 
70
<p>
 
71
Prior to 2.10, <a href="glib-Memory-Allocators.html#GAllocator"><span class="type">GAllocator</span></a> was used as an efficient way to allocate 
 
72
small pieces of memory for use with the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>, <a href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> and <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> data 
 
73
structures. Since 2.10, it has been completely replaced by the 
 
74
<a href="glib-Memory-Slices.html" title="Memory Slices">slice allocator</a> and deprecated.
 
75
</p>
 
76
</div>
 
77
<div class="refsect1" lang="en">
 
78
<a name="id3155979"></a><h2>Details</h2>
 
79
<div class="refsect2" lang="en">
 
80
<a name="id3155989"></a><h3>
 
81
<a name="GAllocator"></a>GAllocator</h3>
 
82
<a class="indexterm" name="id3156004"></a><pre class="programlisting">typedef struct _GAllocator GAllocator;</pre>
 
83
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
 
84
<h3 class="title">Warning</h3>
 
85
<p><code class="literal">GAllocator</code> is deprecated and should not be used in newly-written code.</p>
 
86
</div>
 
87
<p>
 
88
The <span class="structname">GAllocator</span> struct contains private data. and 
 
89
should only be accessed using the following functions.
 
90
</p>
 
91
</div>
 
92
<hr>
 
93
<div class="refsect2" lang="en">
 
94
<a name="id3156037"></a><h3>
 
95
<a name="g-allocator-new"></a>g_allocator_new ()</h3>
 
96
<a class="indexterm" name="id3156052"></a><pre class="programlisting"><a href="glib-Memory-Allocators.html#GAllocator">GAllocator</a>*         g_allocator_new                     (const <a href="glib-Basic-Types.html#gchar">gchar</a> *name,
 
97
                                                         <a href="glib-Basic-Types.html#guint">guint</a> n_preallocs);</pre>
 
98
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
 
99
<h3 class="title">Warning</h3>
 
100
<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 href="glib-Memory-Slices.html" title="Memory Slices">slice allocator</a>
 
101
instead</p>
 
102
</div>
 
103
<p>
 
104
Creates a new <a href="glib-Memory-Allocators.html#GAllocator"><span class="type">GAllocator</span></a>.
 
105
</p>
 
106
<div class="variablelist"><table border="0">
 
107
<col align="left" valign="top">
 
108
<tbody>
 
109
<tr>
 
110
<td><span class="term"><em class="parameter"><code>name</code></em>&#160;:</span></td>
 
111
<td>the name of the <a href="glib-Memory-Allocators.html#GAllocator"><span class="type">GAllocator</span></a>. This name is used to set the name of the
 
112
<a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a> used by the <a href="glib-Memory-Allocators.html#GAllocator"><span class="type">GAllocator</span></a>, and is only used for debugging.
 
113
</td>
 
114
</tr>
 
115
<tr>
 
116
<td><span class="term"><em class="parameter"><code>n_preallocs</code></em>&#160;:</span></td>
 
117
<td>the number of elements in each block of memory allocated.
 
118
Larger blocks mean less calls to <a href="glib-Memory-Allocation.html#g-malloc"><code class="function">g_malloc()</code></a>, but some memory may be wasted.
 
119
(GLib uses 128 elements per block by default.) The value must be between 1
 
120
and 65535.
 
121
</td>
 
122
</tr>
 
123
<tr>
 
124
<td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td>
 
125
<td>a new <a href="glib-Memory-Allocators.html#GAllocator"><span class="type">GAllocator</span></a>.
 
126
</td>
 
127
</tr>
 
128
</tbody>
 
129
</table></div>
 
130
</div>
 
131
<hr>
 
132
<div class="refsect2" lang="en">
 
133
<a name="id3156205"></a><h3>
 
134
<a name="g-allocator-free"></a>g_allocator_free ()</h3>
 
135
<a class="indexterm" name="id3156220"></a><pre class="programlisting">void                g_allocator_free                    (<a href="glib-Memory-Allocators.html#GAllocator">GAllocator</a> *allocator);</pre>
 
136
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
 
137
<h3 class="title">Warning</h3>
 
138
<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 href="glib-Memory-Slices.html" title="Memory Slices">slice allocator</a>
 
139
instead</p>
 
140
</div>
 
141
<p>
 
142
Frees all of the memory allocated by the <a href="glib-Memory-Allocators.html#GAllocator"><span class="type">GAllocator</span></a>.
 
143
</p>
 
144
<div class="variablelist"><table border="0">
 
145
<col align="left" valign="top">
 
146
<tbody><tr>
 
147
<td><span class="term"><em class="parameter"><code>allocator</code></em>&#160;:</span></td>
 
148
<td>a <a href="glib-Memory-Allocators.html#GAllocator"><span class="type">GAllocator</span></a>.
 
149
</td>
 
150
</tr></tbody>
 
151
</table></div>
 
152
</div>
 
153
</div>
 
154
</div>
 
155
</body>
 
156
</html>