1
2
3
4
5<!DOCTYPE html>
6<html lang="en">
7<head>
8    <title>ImageMagick: MagickCore, C API for ImageMagick: Memory Allocation</title>
9  <meta charset="utf-8" />
10  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
11  <meta name="viewport" content="width=device-width, initial-scale=1" />
12  <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
13  <meta name="application-name" content="ImageMagick"/>
14  <meta name="description" content="ImageMagick® is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, JPEG-2000, GIF, WebP, Postscript, PDF, and SVG. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves."/>
15  <meta name="application-url" content="http://www.imagemagick.org"/>
16  <meta name="generator" content="PHP"/>
17  <meta name="keywords" content="magickcore, c, api, for, imagemagick:, memory, allocation, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert"/>
18  <meta name="rating" content="GENERAL"/>
19  <meta name="robots" content="INDEX, FOLLOW"/>
20  <meta name="generator" content="ImageMagick Studio LLC"/>
21  <meta name="author" content="ImageMagick Studio LLC"/>
22  <meta name="revisit-after" content="2 DAYS"/>
23  <meta name="resource-type" content="document"/>
24  <meta name="copyright" content="Copyright (c) 1999-2016 ImageMagick Studio LLC"/>
25  <meta name="distribution" content="Global"/>
26  <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1"/>
27  <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
28  <link rel="icon" href="/images/wand.png"/>
29  <link rel="shortcut icon" href="/images/wand.ico"/>
30  <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Roboto:900,400,400italic,700,700italic,300,300italic|Open+Sans:300italic,400italic,700italic,300,400,600,700">
31  <link rel="stylesheet" href="/css/magick.html"/>
32</head>
33<body>
34<div class="main">
35<div class="magick-masthead">
36  <div class="container">
37    <script async="async" src="http://localhost/pagead/js/adsbygoogle.js"></script>    <ins class="adsbygoogle"
38         style="display:block"
39         data-ad-client="ca-pub-3129977114552745"
40         data-ad-slot="6345125851"
41         data-ad-format="auto"></ins>
42    <script>
43      (adsbygoogle = window.adsbygoogle || []).push({});
44    </script>
45    <nav class="magick-nav">
46      <a class="magick-nav-item " href="/index.html">Home</a>
47      <a class="magick-nav-item " href="/binary-releases.html">Download</a>
48      <a class="magick-nav-item " href="/command-line-tools.html">Tools</a>
49      <a class="magick-nav-item " href="/command-line-processing.html">Command-line</a>
50      <a class="magick-nav-item " href="/resources.html">Resources</a>
51      <a class="magick-nav-item " href="api.html">Develop</a>
52      <a class="magick-nav-item " href="http://www.imagemagick.org/script/search.php">Search</a>
53      <a class="magick-nav-item pull-right" href="https://www.imagemagick.org/discourse-server/">Community</a>
54    </nav>
55  </div>
56</div>
57<div class="container">
58<div class="magick-header">
59<p class="text-center"><a href="memory.html#AcquireAlignedMemory">AcquireAlignedMemory</a> &#8226; <a href="memory.html#AcquireMagickMemory">AcquireMagickMemory</a> &#8226; <a href="memory.html#AcquireQuantumMemory">AcquireQuantumMemory</a> &#8226; <a href="memory.html#AcquireVirtualMemory">AcquireVirtualMemory</a> &#8226; <a href="memory.html#CopyMagickMemory">CopyMagickMemory</a> &#8226; <a href="memory.html#GetMagickMemoryMethods">GetMagickMemoryMethods</a> &#8226; <a href="memory.html#GetVirtualMemoryBlob">GetVirtualMemoryBlob</a> &#8226; <a href="memory.html#RelinquishAlignedMemory">RelinquishAlignedMemory</a> &#8226; <a href="memory.html#RelinquishMagickMemory">RelinquishMagickMemory</a> &#8226; <a href="memory.html#RelinquishVirtualMemory">RelinquishVirtualMemory</a> &#8226; <a href="memory.html#ResetMagickMemory">ResetMagickMemory</a> &#8226; <a href="memory.html#ResizeMagickMemory">ResizeMagickMemory</a> &#8226; <a href="memory.html#ResizeQuantumMemory">ResizeQuantumMemory</a> &#8226; <a href="memory.html#SetMagickMemoryMethods">SetMagickMemoryMethods</a></p>
60
61<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="AcquireAlignedMemory">AcquireAlignedMemory</a></h2>
62
63<p>AcquireAlignedMemory() returns a pointer to a block of memory at least size bytes whose address is a multiple of 16*sizeof(void *).</p>
64
65<p>The format of the AcquireAlignedMemory method is:</p>
66
67<pre class="text">
68void *AcquireAlignedMemory(const size_t count,const size_t quantum)
69</pre>
70
71<p>A description of each parameter follows:</p>
72
73<dd>
74</dd>
75
76<dd> </dd>
77<dl class="dl-horizontal">
78<dt>count</dt>
79<dd>the number of quantum elements to allocate. </dd>
80
81<dd> </dd>
82<dt>quantum</dt>
83<dd>the number of bytes in each quantum. </dd>
84
85<dd>  </dd>
86</dl>
87<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="AcquireMagickMemory">AcquireMagickMemory</a></h2>
88
89<p>AcquireMagickMemory() returns a pointer to a block of memory at least size bytes suitably aligned for any use.</p>
90
91<p>The format of the AcquireMagickMemory method is:</p>
92
93<pre class="text">
94void *AcquireMagickMemory(const size_t size)
95</pre>
96
97<p>A description of each parameter follows:</p>
98
99<dd>
100</dd>
101
102<dd> </dd>
103<dl class="dl-horizontal">
104<dt>size</dt>
105<dd>the size of the memory in bytes to allocate. </dd>
106
107<dd>  </dd>
108</dl>
109<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="AcquireQuantumMemory">AcquireQuantumMemory</a></h2>
110
111<p>AcquireQuantumMemory() returns a pointer to a block of memory at least count * quantum bytes suitably aligned for any use.</p>
112
113<p>The format of the AcquireQuantumMemory method is:</p>
114
115<pre class="text">
116void *AcquireQuantumMemory(const size_t count,const size_t quantum)
117</pre>
118
119<p>A description of each parameter follows:</p>
120
121<dd>
122</dd>
123
124<dd> </dd>
125<dl class="dl-horizontal">
126<dt>count</dt>
127<dd>the number of quantum elements to allocate. </dd>
128
129<dd> </dd>
130<dt>quantum</dt>
131<dd>the number of bytes in each quantum. </dd>
132
133<dd>  </dd>
134</dl>
135<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="AcquireVirtualMemory">AcquireVirtualMemory</a></h2>
136
137<p>AcquireVirtualMemory() allocates a pointer to a block of memory at least size bytes suitably aligned for any use.</p>
138
139<p>The format of the AcquireVirtualMemory method is:</p>
140
141<pre class="text">
142MemoryInfo *AcquireVirtualMemory(const size_t count,const size_t quantum)
143</pre>
144
145<p>A description of each parameter follows:</p>
146
147<dd>
148</dd>
149
150<dd> </dd>
151<dl class="dl-horizontal">
152<dt>count</dt>
153<dd>the number of quantum elements to allocate. </dd>
154
155<dd> </dd>
156<dt>quantum</dt>
157<dd>the number of bytes in each quantum. </dd>
158
159<dd>  </dd>
160</dl>
161<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="CopyMagickMemory">CopyMagickMemory</a></h2>
162
163<p>CopyMagickMemory() copies size bytes from memory area source to the destination.  Copying between objects that overlap will take place correctly.  It returns destination.</p>
164
165<p>The format of the CopyMagickMemory method is:</p>
166
167<pre class="text">
168void *CopyMagickMemory(void *destination,const void *source,
169  const size_t size)
170</pre>
171
172<p>A description of each parameter follows:</p>
173
174<dd>
175</dd>
176
177<dd> </dd>
178<dl class="dl-horizontal">
179<dt>destination</dt>
180<dd>the destination. </dd>
181
182<dd> </dd>
183<dt>source</dt>
184<dd>the source. </dd>
185
186<dd> </dd>
187<dt>size</dt>
188<dd>the size of the memory in bytes to allocate. </dd>
189
190<dd>  </dd>
191</dl>
192<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="GetMagickMemoryMethods">GetMagickMemoryMethods</a></h2>
193
194<p>GetMagickMemoryMethods() gets the methods to acquire, resize, and destroy memory.</p>
195
196<p>The format of the GetMagickMemoryMethods() method is:</p>
197
198<pre class="text">
199void GetMagickMemoryMethods(AcquireMemoryHandler *acquire_memory_handler,
200  ResizeMemoryHandler *resize_memory_handler,
201  DestroyMemoryHandler *destroy_memory_handler)
202</pre>
203
204<p>A description of each parameter follows:</p>
205
206<dd>
207</dd>
208
209<dd> </dd>
210<dl class="dl-horizontal">
211<dt>acquire_memory_handler</dt>
212<dd>method to acquire memory (e.g. malloc). </dd>
213
214<dd> </dd>
215<dt>resize_memory_handler</dt>
216<dd>method to resize memory (e.g. realloc). </dd>
217
218<dd> </dd>
219<dt>destroy_memory_handler</dt>
220<dd>method to destroy memory (e.g. free). </dd>
221
222<dd>  </dd>
223</dl>
224<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="GetVirtualMemoryBlob">GetVirtualMemoryBlob</a></h2>
225
226<p>GetVirtualMemoryBlob() returns the virtual memory blob associated with the specified MemoryInfo structure.</p>
227
228<p>The format of the GetVirtualMemoryBlob method is:</p>
229
230<pre class="text">
231void *GetVirtualMemoryBlob(const MemoryInfo *memory_info)
232</pre>
233
234<p>A description of each parameter follows:</p>
235
236<dd>
237</dd>
238
239<dd> </dd>
240<dl class="dl-horizontal">
241<dt>memory_info</dt>
242<dd>The MemoryInfo structure.  </dd>
243</dl>
244<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="RelinquishAlignedMemory">RelinquishAlignedMemory</a></h2>
245
246<p>RelinquishAlignedMemory() frees memory acquired with AcquireAlignedMemory() or reuse.</p>
247
248<p>The format of the RelinquishAlignedMemory method is:</p>
249
250<pre class="text">
251void *RelinquishAlignedMemory(void *memory)
252</pre>
253
254<p>A description of each parameter follows:</p>
255
256<dd>
257</dd>
258
259<dd> </dd>
260<dl class="dl-horizontal">
261<dt>memory</dt>
262<dd>A pointer to a block of memory to free for reuse. </dd>
263
264<dd>  </dd>
265</dl>
266<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="RelinquishMagickMemory">RelinquishMagickMemory</a></h2>
267
268<p>RelinquishMagickMemory() frees memory acquired with AcquireMagickMemory() or AcquireQuantumMemory() for reuse.</p>
269
270<p>The format of the RelinquishMagickMemory method is:</p>
271
272<pre class="text">
273void *RelinquishMagickMemory(void *memory)
274</pre>
275
276<p>A description of each parameter follows:</p>
277
278<dd>
279</dd>
280
281<dd> </dd>
282<dl class="dl-horizontal">
283<dt>memory</dt>
284<dd>A pointer to a block of memory to free for reuse. </dd>
285
286<dd>  </dd>
287</dl>
288<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="RelinquishVirtualMemory">RelinquishVirtualMemory</a></h2>
289
290<p>RelinquishVirtualMemory() frees memory acquired with AcquireVirtualMemory().</p>
291
292<p>The format of the RelinquishVirtualMemory method is:</p>
293
294<pre class="text">
295MemoryInfo *RelinquishVirtualMemory(MemoryInfo *memory_info)
296</pre>
297
298<p>A description of each parameter follows:</p>
299
300<dd>
301</dd>
302
303<dd> </dd>
304<dl class="dl-horizontal">
305<dt>memory_info</dt>
306<dd>A pointer to a block of memory to free for reuse. </dd>
307
308<dd>  </dd>
309</dl>
310<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="ResetMagickMemory">ResetMagickMemory</a></h2>
311
312<p>ResetMagickMemory() fills the first size bytes of the memory area pointed to by memory with the constant byte c.</p>
313
314<p>The format of the ResetMagickMemory method is:</p>
315
316<pre class="text">
317void *ResetMagickMemory(void *memory,int byte,const size_t size)
318</pre>
319
320<p>A description of each parameter follows:</p>
321
322<dd>
323</dd>
324
325<dd> </dd>
326<dl class="dl-horizontal">
327<dt>memory</dt>
328<dd>a pointer to a memory allocation. </dd>
329
330<dd> </dd>
331<dt>byte</dt>
332<dd>set the memory to this value. </dd>
333
334<dd> </dd>
335<dt>size</dt>
336<dd>size of the memory to reset. </dd>
337
338<dd>  </dd>
339</dl>
340<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="ResizeMagickMemory">ResizeMagickMemory</a></h2>
341
342<p>ResizeMagickMemory() changes the size of the memory and returns a pointer to the (possibly moved) block.  The contents will be unchanged up to the lesser of the new and old sizes.</p>
343
344<p>The format of the ResizeMagickMemory method is:</p>
345
346<pre class="text">
347void *ResizeMagickMemory(void *memory,const size_t size)
348</pre>
349
350<p>A description of each parameter follows:</p>
351
352<dd>
353</dd>
354
355<dd> </dd>
356<dl class="dl-horizontal">
357<dt>memory</dt>
358<dd>A pointer to a memory allocation. </dd>
359
360<dd> </dd>
361<dt>size</dt>
362<dd>the new size of the allocated memory. </dd>
363
364<dd>  </dd>
365</dl>
366<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="ResizeQuantumMemory">ResizeQuantumMemory</a></h2>
367
368<p>ResizeQuantumMemory() changes the size of the memory and returns a pointer to the (possibly moved) block.  The contents will be unchanged up to the lesser of the new and old sizes.</p>
369
370<p>The format of the ResizeQuantumMemory method is:</p>
371
372<pre class="text">
373void *ResizeQuantumMemory(void *memory,const size_t count,
374  const size_t quantum)
375</pre>
376
377<p>A description of each parameter follows:</p>
378
379<dd>
380</dd>
381
382<dd> </dd>
383<dl class="dl-horizontal">
384<dt>memory</dt>
385<dd>A pointer to a memory allocation. </dd>
386
387<dd> </dd>
388<dt>count</dt>
389<dd>the number of quantum elements to allocate. </dd>
390
391<dd> </dd>
392<dt>quantum</dt>
393<dd>the number of bytes in each quantum. </dd>
394
395<dd>  </dd>
396</dl>
397<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="SetMagickMemoryMethods">SetMagickMemoryMethods</a></h2>
398
399<p>SetMagickMemoryMethods() sets the methods to acquire, resize, and destroy memory. Your custom memory methods must be set prior to the MagickCoreGenesis() method.</p>
400
401<p>The format of the SetMagickMemoryMethods() method is:</p>
402
403<pre class="text">
404SetMagickMemoryMethods(AcquireMemoryHandler acquire_memory_handler,
405  ResizeMemoryHandler resize_memory_handler,
406  DestroyMemoryHandler destroy_memory_handler)
407</pre>
408
409<p>A description of each parameter follows:</p>
410
411<dd>
412</dd>
413
414<dd> </dd>
415<dl class="dl-horizontal">
416<dt>acquire_memory_handler</dt>
417<dd>method to acquire memory (e.g. malloc). </dd>
418
419<dd> </dd>
420<dt>resize_memory_handler</dt>
421<dd>method to resize memory (e.g. realloc). </dd>
422
423<dd> </dd>
424<dt>destroy_memory_handler</dt>
425<dd>method to destroy memory (e.g. free). </dd>
426
427<dd>  </dd>
428</dl>
429</div>
430  <footer class="magick-footer">
431    <p><a href="/support.html">Donate</a> •
432     <a href="/sitemap.html">Sitemap</a> •
433    <a href="/links.html">Related</a> •
434    <a href="/architecture.html">Architecture</a>
435</p>
436    <p><a href="memory.html#">Back to top</a> •
437    <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x89AB63D48277377A">Public Key</a> •
438    <a href="http://www.imagemagick.org/script/contact.php">Contact Us</a></p>
439        <p><small>©  1999-2016 ImageMagick Studio LLC</small></p>
440  </footer>
441</div><!-- /.container -->
442
443  <script src="https://localhost/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
444  <script src="/js/magick.html"></script>
445</div>
446</body>
447</html>
448