blob: 4405801218b560d97e2df7935ae93cf5950b2065 [file] [log] [blame]
Cristy594d2772015-11-15 10:47:42 -05001
2
3
4
cristy29dc8652015-05-12 16:26:21 +00005<!DOCTYPE html>
cristy44443b92015-05-05 00:06:07 +00006<html lang="en">
cristy06f63f22012-10-31 00:50:07 +00007<head>
Cristy594d2772015-11-15 10:47:42 -05008 <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
cristy29f2c972015-07-28 13:37:46 +00009 <title>ImageMagick: MagickCore, C API for ImageMagick: Memory Allocation</title>
Cristy594d2772015-11-15 10:47:42 -050010 <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
11 <meta name="application-name" content="ImageMagick"/>
12 <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."/>
13 <meta name="application-url" content="http://www.imagemagick.org"/>
14 <meta name="generator" content="PHP"/>
15 <meta name="keywords" content="magickcore, c, api, for, imagemagick:, memory, allocation, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert"/>
16 <meta name="rating" content="GENERAL"/>
17 <meta name="robots" content="INDEX, FOLLOW"/>
18 <meta name="generator" content="ImageMagick Studio LLC"/>
19 <meta name="author" content="ImageMagick Studio LLC"/>
20 <meta name="revisit-after" content="2 DAYS"/>
21 <meta name="resource-type" content="document"/>
Cristyce4a3552015-12-14 13:53:35 -050022 <meta name="copyright" content="Copyright (c) 1999-2015 ImageMagick Studio LLC"/>
Cristy594d2772015-11-15 10:47:42 -050023 <meta name="distribution" content="Global"/>
24 <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1"/>
25 <link rel="icon" href="../images/wand.png"/>
26 <link rel="shortcut icon" href="../images/wand.ico"/>
27 <link rel="stylesheet" href="../css/magick.html"/>
cristy06f63f22012-10-31 00:50:07 +000028</head>
cristy44443b92015-05-05 00:06:07 +000029<body>
cristy06f63f22012-10-31 00:50:07 +000030<div class="main">
cristy44443b92015-05-05 00:06:07 +000031<div class="magick-masthead">
32 <div class="container">
Cristye93be682015-11-26 09:07:51 -050033 <script async="async" src="http://localhost/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle"
Cristy594d2772015-11-15 10:47:42 -050034 style="display:block"
35 data-ad-client="ca-pub-3129977114552745"
36 data-ad-slot="6345125851"
37 data-ad-format="auto"></ins>
cristy29f2c972015-07-28 13:37:46 +000038 <script>
Cristy542697a2015-10-12 20:10:32 -040039 (adsbygoogle = window.adsbygoogle || []).push({});
cristy44443b92015-05-05 00:06:07 +000040 </script>
cristy44443b92015-05-05 00:06:07 +000041 <nav class="magick-nav">
cristy2f563d42015-05-06 23:36:51 +000042 <a class="magick-nav-item " href="../index.html">Home</a>
cristyea2793e2015-05-31 16:52:26 +000043 <a class="magick-nav-item " href="../binary-releases.html">Download</a>
cristy38185362015-05-07 20:09:56 +000044 <a class="magick-nav-item " href="../command-line-tools.html">Tools</a>
Cristye93be682015-11-26 09:07:51 -050045 <a class="magick-nav-item " href="../command-line-processing.html">Command-line</a>
cristyea2793e2015-05-31 16:52:26 +000046 <a class="magick-nav-item " href="../resources.html">Resources</a>
47 <a class="magick-nav-item " href="api.html">Develop</a>
cristy5b8fe762015-06-09 16:24:03 +000048 <a class="magick-nav-item " href="http://nextgen.imagemagick.org/script/search.php">Search</a>
cristya1890f02015-05-15 23:32:44 +000049 <a class="magick-nav-item pull-right" href="http://www.imagemagick.org/discourse-server/">Community</a>
cristy44443b92015-05-05 00:06:07 +000050 </nav>
51 </div>
52</div>
53<div class="container">
cristy4e638cd2015-05-07 16:47:40 +000054<div class="magick-header">
Cristy594d2772015-11-15 10:47:42 -050055<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>
cristy06f63f22012-10-31 00:50:07 +000056
Cristye93be682015-11-26 09:07:51 -050057<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="AcquireAlignedMemory">AcquireAlignedMemory</a></h2>
cristycecc9492015-06-09 16:53:50 +000058
59<p>AcquireAlignedMemory() returns a pointer to a block of memory at least size bytes whose address is a multiple of 16*sizeof(void *).</p>
60
61<p>The format of the AcquireAlignedMemory method is:</p>
62
63<pre class="text">
64void *AcquireAlignedMemory(const size_t count,const size_t quantum)
65</pre>
66
67<p>A description of each parameter follows:</p>
68
69<dd>
70</dd>
71
72<dd> </dd>
73<dl class="dl-horizontal">
74<dt>count</dt>
75<dd>the number of quantum elements to allocate. </dd>
76
77<dd> </dd>
78<dt>quantum</dt>
79<dd>the number of bytes in each quantum. </dd>
80
81<dd> </dd>
82</dl>
Cristye93be682015-11-26 09:07:51 -050083<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="AcquireMagickMemory">AcquireMagickMemory</a></h2>
cristycecc9492015-06-09 16:53:50 +000084
85<p>AcquireMagickMemory() returns a pointer to a block of memory at least size bytes suitably aligned for any use.</p>
86
87<p>The format of the AcquireMagickMemory method is:</p>
88
89<pre class="text">
90void *AcquireMagickMemory(const size_t size)
91</pre>
92
93<p>A description of each parameter follows:</p>
94
95<dd>
96</dd>
97
98<dd> </dd>
99<dl class="dl-horizontal">
100<dt>size</dt>
101<dd>the size of the memory in bytes to allocate. </dd>
102
103<dd> </dd>
104</dl>
Cristye93be682015-11-26 09:07:51 -0500105<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="AcquireQuantumMemory">AcquireQuantumMemory</a></h2>
cristycecc9492015-06-09 16:53:50 +0000106
107<p>AcquireQuantumMemory() returns a pointer to a block of memory at least count * quantum bytes suitably aligned for any use.</p>
108
109<p>The format of the AcquireQuantumMemory method is:</p>
110
111<pre class="text">
112void *AcquireQuantumMemory(const size_t count,const size_t quantum)
113</pre>
114
115<p>A description of each parameter follows:</p>
116
117<dd>
118</dd>
119
120<dd> </dd>
121<dl class="dl-horizontal">
122<dt>count</dt>
123<dd>the number of quantum elements to allocate. </dd>
124
125<dd> </dd>
126<dt>quantum</dt>
127<dd>the number of bytes in each quantum. </dd>
128
129<dd> </dd>
130</dl>
Cristye93be682015-11-26 09:07:51 -0500131<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="AcquireVirtualMemory">AcquireVirtualMemory</a></h2>
cristycecc9492015-06-09 16:53:50 +0000132
133<p>AcquireVirtualMemory() allocates a pointer to a block of memory at least size bytes suitably aligned for any use.</p>
134
135<p>The format of the AcquireVirtualMemory method is:</p>
136
137<pre class="text">
138MemoryInfo *AcquireVirtualMemory(const size_t count,const size_t quantum)
139</pre>
140
141<p>A description of each parameter follows:</p>
142
143<dd>
144</dd>
145
146<dd> </dd>
147<dl class="dl-horizontal">
148<dt>count</dt>
149<dd>the number of quantum elements to allocate. </dd>
150
151<dd> </dd>
152<dt>quantum</dt>
153<dd>the number of bytes in each quantum. </dd>
154
155<dd> </dd>
156</dl>
Cristye93be682015-11-26 09:07:51 -0500157<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="CopyMagickMemory">CopyMagickMemory</a></h2>
cristycecc9492015-06-09 16:53:50 +0000158
159<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>
160
161<p>The format of the CopyMagickMemory method is:</p>
162
163<pre class="text">
164void *CopyMagickMemory(void *destination,const void *source,
165 const size_t size)
166</pre>
167
168<p>A description of each parameter follows:</p>
169
170<dd>
171</dd>
172
173<dd> </dd>
174<dl class="dl-horizontal">
175<dt>destination</dt>
176<dd>the destination. </dd>
177
178<dd> </dd>
179<dt>source</dt>
180<dd>the source. </dd>
181
182<dd> </dd>
183<dt>size</dt>
184<dd>the size of the memory in bytes to allocate. </dd>
185
186<dd> </dd>
187</dl>
Cristye93be682015-11-26 09:07:51 -0500188<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="GetMagickMemoryMethods">GetMagickMemoryMethods</a></h2>
cristycecc9492015-06-09 16:53:50 +0000189
190<p>GetMagickMemoryMethods() gets the methods to acquire, resize, and destroy memory.</p>
191
192<p>The format of the GetMagickMemoryMethods() method is:</p>
193
194<pre class="text">
195void GetMagickMemoryMethods(AcquireMemoryHandler *acquire_memory_handler,
196 ResizeMemoryHandler *resize_memory_handler,
197 DestroyMemoryHandler *destroy_memory_handler)
198</pre>
199
200<p>A description of each parameter follows:</p>
201
202<dd>
203</dd>
204
205<dd> </dd>
206<dl class="dl-horizontal">
207<dt>acquire_memory_handler</dt>
208<dd>method to acquire memory (e.g. malloc). </dd>
209
210<dd> </dd>
211<dt>resize_memory_handler</dt>
212<dd>method to resize memory (e.g. realloc). </dd>
213
214<dd> </dd>
215<dt>destroy_memory_handler</dt>
216<dd>method to destroy memory (e.g. free). </dd>
217
218<dd> </dd>
219</dl>
Cristye93be682015-11-26 09:07:51 -0500220<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="GetVirtualMemoryBlob">GetVirtualMemoryBlob</a></h2>
cristycecc9492015-06-09 16:53:50 +0000221
222<p>GetVirtualMemoryBlob() returns the virtual memory blob associated with the specified MemoryInfo structure.</p>
223
224<p>The format of the GetVirtualMemoryBlob method is:</p>
225
226<pre class="text">
227void *GetVirtualMemoryBlob(const MemoryInfo *memory_info)
228</pre>
229
230<p>A description of each parameter follows:</p>
231
232<dd>
233</dd>
234
235<dd> </dd>
236<dl class="dl-horizontal">
237<dt>memory_info</dt>
238<dd>The MemoryInfo structure. </dd>
239</dl>
Cristye93be682015-11-26 09:07:51 -0500240<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="RelinquishAlignedMemory">RelinquishAlignedMemory</a></h2>
cristycecc9492015-06-09 16:53:50 +0000241
242<p>RelinquishAlignedMemory() frees memory acquired with AcquireAlignedMemory() or reuse.</p>
243
244<p>The format of the RelinquishAlignedMemory method is:</p>
245
246<pre class="text">
247void *RelinquishAlignedMemory(void *memory)
248</pre>
249
250<p>A description of each parameter follows:</p>
251
252<dd>
253</dd>
254
255<dd> </dd>
256<dl class="dl-horizontal">
257<dt>memory</dt>
258<dd>A pointer to a block of memory to free for reuse. </dd>
259
260<dd> </dd>
261</dl>
Cristye93be682015-11-26 09:07:51 -0500262<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="RelinquishMagickMemory">RelinquishMagickMemory</a></h2>
cristycecc9492015-06-09 16:53:50 +0000263
264<p>RelinquishMagickMemory() frees memory acquired with AcquireMagickMemory() or AcquireQuantumMemory() for reuse.</p>
265
266<p>The format of the RelinquishMagickMemory method is:</p>
267
268<pre class="text">
269void *RelinquishMagickMemory(void *memory)
270</pre>
271
272<p>A description of each parameter follows:</p>
273
274<dd>
275</dd>
276
277<dd> </dd>
278<dl class="dl-horizontal">
279<dt>memory</dt>
280<dd>A pointer to a block of memory to free for reuse. </dd>
281
282<dd> </dd>
283</dl>
Cristye93be682015-11-26 09:07:51 -0500284<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="RelinquishVirtualMemory">RelinquishVirtualMemory</a></h2>
cristycecc9492015-06-09 16:53:50 +0000285
286<p>RelinquishVirtualMemory() frees memory acquired with AcquireVirtualMemory().</p>
287
288<p>The format of the RelinquishVirtualMemory method is:</p>
289
290<pre class="text">
291MemoryInfo *RelinquishVirtualMemory(MemoryInfo *memory_info)
292</pre>
293
294<p>A description of each parameter follows:</p>
295
296<dd>
297</dd>
298
299<dd> </dd>
300<dl class="dl-horizontal">
301<dt>memory_info</dt>
302<dd>A pointer to a block of memory to free for reuse. </dd>
303
304<dd> </dd>
305</dl>
Cristye93be682015-11-26 09:07:51 -0500306<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="ResetMagickMemory">ResetMagickMemory</a></h2>
cristycecc9492015-06-09 16:53:50 +0000307
308<p>ResetMagickMemory() fills the first size bytes of the memory area pointed to by memory with the constant byte c.</p>
309
310<p>The format of the ResetMagickMemory method is:</p>
311
312<pre class="text">
313void *ResetMagickMemory(void *memory,int byte,const size_t size)
314</pre>
315
316<p>A description of each parameter follows:</p>
317
318<dd>
319</dd>
320
321<dd> </dd>
322<dl class="dl-horizontal">
323<dt>memory</dt>
324<dd>a pointer to a memory allocation. </dd>
325
326<dd> </dd>
327<dt>byte</dt>
328<dd>set the memory to this value. </dd>
329
330<dd> </dd>
331<dt>size</dt>
332<dd>size of the memory to reset. </dd>
333
334<dd> </dd>
335</dl>
Cristye93be682015-11-26 09:07:51 -0500336<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="ResizeMagickMemory">ResizeMagickMemory</a></h2>
cristycecc9492015-06-09 16:53:50 +0000337
338<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>
339
340<p>The format of the ResizeMagickMemory method is:</p>
341
342<pre class="text">
343void *ResizeMagickMemory(void *memory,const size_t size)
344</pre>
345
346<p>A description of each parameter follows:</p>
347
348<dd>
349</dd>
350
351<dd> </dd>
352<dl class="dl-horizontal">
353<dt>memory</dt>
354<dd>A pointer to a memory allocation. </dd>
355
356<dd> </dd>
357<dt>size</dt>
358<dd>the new size of the allocated memory. </dd>
359
360<dd> </dd>
361</dl>
Cristye93be682015-11-26 09:07:51 -0500362<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="ResizeQuantumMemory">ResizeQuantumMemory</a></h2>
cristycecc9492015-06-09 16:53:50 +0000363
364<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>
365
366<p>The format of the ResizeQuantumMemory method is:</p>
367
368<pre class="text">
369void *ResizeQuantumMemory(void *memory,const size_t count,
370 const size_t quantum)
371</pre>
372
373<p>A description of each parameter follows:</p>
374
375<dd>
376</dd>
377
378<dd> </dd>
379<dl class="dl-horizontal">
380<dt>memory</dt>
381<dd>A pointer to a memory allocation. </dd>
382
383<dd> </dd>
384<dt>count</dt>
385<dd>the number of quantum elements to allocate. </dd>
386
387<dd> </dd>
388<dt>quantum</dt>
389<dd>the number of bytes in each quantum. </dd>
390
391<dd> </dd>
392</dl>
Cristye93be682015-11-26 09:07:51 -0500393<h2><a href="http://www.imagemagick.org/api/MagickCore/memory_8c.html" id="SetMagickMemoryMethods">SetMagickMemoryMethods</a></h2>
cristycecc9492015-06-09 16:53:50 +0000394
395<p>SetMagickMemoryMethods() sets the methods to acquire, resize, and destroy memory. Your custom memory methods must be set prior to the MagickCoreGenesis() method.</p>
396
397<p>The format of the SetMagickMemoryMethods() method is:</p>
398
399<pre class="text">
400SetMagickMemoryMethods(AcquireMemoryHandler acquire_memory_handler,
401 ResizeMemoryHandler resize_memory_handler,
402 DestroyMemoryHandler destroy_memory_handler)
403</pre>
404
405<p>A description of each parameter follows:</p>
406
407<dd>
408</dd>
409
410<dd> </dd>
411<dl class="dl-horizontal">
412<dt>acquire_memory_handler</dt>
413<dd>method to acquire memory (e.g. malloc). </dd>
414
415<dd> </dd>
416<dt>resize_memory_handler</dt>
417<dd>method to resize memory (e.g. realloc). </dd>
418
419<dd> </dd>
420<dt>destroy_memory_handler</dt>
421<dd>method to destroy memory (e.g. free). </dd>
422
423<dd> </dd>
424</dl>
cristy06f63f22012-10-31 00:50:07 +0000425</div>
cristy44443b92015-05-05 00:06:07 +0000426 <footer class="magick-footer">
cristy29f2c972015-07-28 13:37:46 +0000427 <p><a href="../support.html">Donate</a>
428 <a href="../sitemap.html">Sitemap</a>
cristy38185362015-05-07 20:09:56 +0000429 <a href="../links.html">Related</a>
cristy29f2c972015-07-28 13:37:46 +0000430 <a href="../architecture.html">Architecture</a>
cristy44443b92015-05-05 00:06:07 +0000431</p>
432 <p><a href="memory.html#">Back to top</a>
cristyea2793e2015-05-31 16:52:26 +0000433 <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&amp;search=0x89AB63D48277377A">Public Key</a>
cristy5b8fe762015-06-09 16:24:03 +0000434 <a href="http://nextgen.imagemagick.org/script/contact.php">Contact Us</a></p>
Cristy600583b2016-01-02 14:00:46 -0500435 <p><small>© 1999-2016 ImageMagick Studio LLC</small></p>
cristy44443b92015-05-05 00:06:07 +0000436 </footer>
437</div><!-- /.container -->
cristy06f63f22012-10-31 00:50:07 +0000438
Cristye93be682015-11-26 09:07:51 -0500439 <script src="https://localhost/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
cristy29f2c972015-07-28 13:37:46 +0000440 <script src="http://nextgen.imagemagick.org/js/magick.html"></script>
cristy44cbd482013-08-04 20:53:36 +0000441</div>
cristy06f63f22012-10-31 00:50:07 +0000442</body>
cristy5a367e42015-05-05 12:39:18 +0000443</html>