• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2
3
4
5<!DOCTYPE html>
6<html lang="en">
7<head>
8  <meta charset="utf-8"  />
9  <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1,shrink-to-fit=no"  />
10  <title>ImageMagick - MagickCore, C API: Memory Allocation</title>
11  <meta name="application-name" content="ImageMagick" />
12  <meta name="description" content="Use ImageMagick® to create, edit, compose, and convert bitmap images. Resize an image, crop it, change its shades and colors, add captions, and more." />
13  <meta name="application-url" content="https://imagemagick.org" />
14  <meta name="generator" content="PHP" />
15  <meta name="keywords" content="magickcore, c, api:, 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" />
22  <meta name="copyright" content="Copyright (c) 1999-2020 ImageMagick Studio LLC" />
23  <meta name="distribution" content="Global" />
24  <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1" />
25  <meta property='og:url' content='../../' />
26  <meta property='og:title' content='ImageMagick' />
27  <meta property='og:image' content='../../images/logo.png' />
28  <meta property='og:type' content='website' />
29  <meta property='og:site_name' content='ImageMagick' />
30  <meta property='og:description' content="Convert, Edit, or Compose Bitmap Images" />
31  <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
32  <link href="memory.html" rel="canonical" />
33  <link href="../../images/wand.png" rel="icon" />
34  <link href="../../images/wand.ico" rel="shortcut icon" />
35  <link href="../assets/magick.css" rel="stylesheet" />
36</head>
37<body>
38  <nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
39    <a class="navbar-brand" href="../../"><img class="d-block" id="icon" alt="ImageMagick" width="32" height="32" src="../../images/wand.ico"/></a>
40    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsMagick" aria-controls="navbarsMagick" aria-expanded="false" aria-label="Toggle navigation">
41      <span class="navbar-toggler-icon"></span>
42    </button>
43
44    <div class="navbar-collapse collapse" id="navbarsMagick" style="">
45    <ul class="navbar-nav mr-auto">
46      <li class="nav-item ">
47        <a class="nav-link" href="../../">Home <span class="sr-only">(current)</span></a>
48      </li>
49      <li class="nav-item ">
50        <a class="nav-link" href="../../www/download.html">Download</a>
51      </li>
52      <li class="nav-item ">
53        <a class="nav-link" href="../../www/command-line-tools.html">Tools</a>
54      </li>
55      <li class="nav-item ">
56        <a class="nav-link" href="../../www/command-line-processing.html">Command-line</a>
57      </li>
58      <li class="nav-item ">
59        <a class="nav-link" href="../../www/resources.html">Resources</a>
60      </li>
61      <li class="nav-item ">
62        <a class="nav-link" href="../../www/develop.html">Develop</a>
63      </li>
64      <li class="nav-item">
65        <a class="nav-link" target="_blank" href="https://imagemagick.org/discourse-server/">Community</a>
66      </li>
67    </ul>
68    <form class="form-inline my-2 my-lg-0" action="../https://imagemagick.org/script/search.php">
69      <input class="form-control mr-sm-2" type="text" name="q" placeholder="Search" aria-label="Search">
70      <button class="btn btn-outline-success my-2 my-sm-0" type="submit" name="sa">Search</button>
71    </form>
72    </div>
73  </nav>
74  <div class="container">
75   <script async="async" src="https://localhost/pagead/js/adsbygoogle.js"></script>    <ins class="adsbygoogle"
76         style="display:block"
77         data-ad-client="ca-pub-3129977114552745"
78         data-ad-slot="6345125851"
79         data-full-width-responsive="true"
80         data-ad-format="horizontal"></ins>
81    <script>
82      (adsbygoogle = window.adsbygoogle || []).push({});
83    </script>
84
85  </div>
86
87  <main class="container">
88    <div class="magick-template">
89<div class="magick-header">
90<p class="text-center"><a href="memory.html#AcquireAlignedMemory">AcquireAlignedMemory</a> &#8226; <a href="memory.html#AcquireMagickMemory">AcquireMagickMemory</a> &#8226; <a href="memory.html#AcquireCriticalMemory">AcquireCriticalMemory</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#SetMagickAlignedMemoryMethods">SetMagickAlignedMemoryMethods</a> &#8226; <a href="memory.html#SetMagickMemoryMethods">SetMagickMemoryMethods</a></p>
91
92<h2><a href="../../api/MagickCore/memory_8c.html" id="AcquireAlignedMemory">AcquireAlignedMemory</a></h2>
93
94<p>AcquireAlignedMemory() returns a pointer to a block of memory whose size is at least (count*quantum) bytes, and whose address is aligned on a cache line.</p>
95
96<p>The format of the AcquireAlignedMemory method is:</p>
97
98<pre class="text">
99void *AcquireAlignedMemory(const size_t count,const size_t quantum)
100</pre>
101
102<p>A description of each parameter follows:</p>
103
104<dd>
105</dd>
106
107<dd> </dd>
108<dl class="dl-horizontal">
109<dt>count</dt>
110<dd>the number of objects to allocate contiguously. </dd>
111
112<dd> </dd>
113<dt>quantum</dt>
114<dd>the size (in bytes) of each object. </dd>
115
116<dd>  </dd>
117</dl>
118<h2><a href="../../api/MagickCore/memory_8c.html" id="AcquireMagickMemory">AcquireMagickMemory</a></h2>
119
120<p>AcquireMagickMemory() returns a pointer to a block of memory at least size bytes suitably aligned for any use.</p>
121
122<p>The format of the AcquireMagickMemory method is:</p>
123
124<pre class="text">
125void *AcquireMagickMemory(const size_t size)
126</pre>
127
128<p>A description of each parameter follows:</p>
129
130<dd>
131</dd>
132
133<dd> </dd>
134<dl class="dl-horizontal">
135<dt>size</dt>
136<dd>the size of the memory in bytes to allocate. </dd>
137
138<dd>  </dd>
139</dl>
140<h2><a href="../../api/MagickCore/memory_8c.html" id="AcquireCriticalMemory">AcquireCriticalMemory</a></h2>
141
142<p>AcquireCriticalMemory() is just like AcquireMagickMemory(), throws a fatal exception if the memory cannot be acquired.</p>
143
144<p>That is, AcquireCriticalMemory() returns a pointer to a block of memory that is at least size bytes, and that is suitably aligned for any use; however, if this is not possible, it throws an exception and terminates the program as unceremoniously as possible.</p>
145
146<p>The format of the AcquireCriticalMemory method is:</p>
147
148<pre class="text">
149void *AcquireCriticalMemory(const size_t size)
150</pre>
151
152<p>A description of each parameter follows:</p>
153
154<dd>
155</dd>
156
157<dd> </dd>
158<dl class="dl-horizontal">
159<dt>size</dt>
160<dd>the size (in bytes) of the memory to allocate. </dd>
161
162<dd>  </dd>
163</dl>
164<h2><a href="../../api/MagickCore/memory_8c.html" id="AcquireQuantumMemory">AcquireQuantumMemory</a></h2>
165
166<p>AcquireQuantumMemory() returns a pointer to a block of memory at least count * quantum bytes suitably aligned for any use.</p>
167
168<p>The format of the AcquireQuantumMemory method is:</p>
169
170<pre class="text">
171void *AcquireQuantumMemory(const size_t count,const size_t quantum)
172</pre>
173
174<p>A description of each parameter follows:</p>
175
176<dd>
177</dd>
178
179<dd> </dd>
180<dl class="dl-horizontal">
181<dt>count</dt>
182<dd>the number of objects to allocate contiguously. </dd>
183
184<dd> </dd>
185<dt>quantum</dt>
186<dd>the size (in bytes) of each object. </dd>
187
188<dd>  </dd>
189</dl>
190<h2><a href="../../api/MagickCore/memory_8c.html" id="AcquireVirtualMemory">AcquireVirtualMemory</a></h2>
191
192<p>AcquireVirtualMemory() allocates a pointer to a block of memory at least size bytes suitably aligned for any use. In addition to heap, it also supports memory-mapped and file-based memory-mapped memory requests.</p>
193
194<p>The format of the AcquireVirtualMemory method is:</p>
195
196<pre class="text">
197MemoryInfo *AcquireVirtualMemory(const size_t count,const size_t quantum)
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>count</dt>
208<dd>the number of objects to allocate contiguously. </dd>
209
210<dd> </dd>
211<dt>quantum</dt>
212<dd>the size (in bytes) of each object. </dd>
213
214<dd>  </dd>
215</dl>
216<h2><a href="../../api/MagickCore/memory_8c.html" id="CopyMagickMemory">CopyMagickMemory</a></h2>
217
218<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>
219
220<p>The format of the CopyMagickMemory method is:</p>
221
222<pre class="text">
223void *CopyMagickMemory(void *magick_restrict destination,
224  const void *magick_restrict source,const size_t size)
225</pre>
226
227<p>A description of each parameter follows:</p>
228
229<dd>
230</dd>
231
232<dd> </dd>
233<dl class="dl-horizontal">
234<dt>destination</dt>
235<dd>the destination. </dd>
236
237<dd> </dd>
238<dt>source</dt>
239<dd>the source. </dd>
240
241<dd> </dd>
242<dt>size</dt>
243<dd>the size of the memory in bytes to allocate. </dd>
244
245<dd>  </dd>
246</dl>
247<h2><a href="../../api/MagickCore/memory_8c.html" id="GetMagickMemoryMethods">GetMagickMemoryMethods</a></h2>
248
249<p>GetMagickMemoryMethods() gets the methods to acquire, resize, and destroy memory.</p>
250
251<p>The format of the GetMagickMemoryMethods() method is:</p>
252
253<pre class="text">
254void GetMagickMemoryMethods(AcquireMemoryHandler *acquire_memory_handler,
255  ResizeMemoryHandler *resize_memory_handler,
256  DestroyMemoryHandler *destroy_memory_handler)
257</pre>
258
259<p>A description of each parameter follows:</p>
260
261<dd>
262</dd>
263
264<dd> </dd>
265<dl class="dl-horizontal">
266<dt>acquire_memory_handler</dt>
267<dd>method to acquire memory (e.g. malloc). </dd>
268
269<dd> </dd>
270<dt>resize_memory_handler</dt>
271<dd>method to resize memory (e.g. realloc). </dd>
272
273<dd> </dd>
274<dt>destroy_memory_handler</dt>
275<dd>method to destroy memory (e.g. free). </dd>
276
277<dd>  </dd>
278</dl>
279<h2><a href="../../api/MagickCore/memory_8c.html" id="GetVirtualMemoryBlob">GetVirtualMemoryBlob</a></h2>
280
281<p>GetVirtualMemoryBlob() returns the virtual memory blob associated with the specified MemoryInfo structure.</p>
282
283<p>The format of the GetVirtualMemoryBlob method is:</p>
284
285<pre class="text">
286void *GetVirtualMemoryBlob(const MemoryInfo *memory_info)
287</pre>
288
289<p>A description of each parameter follows:</p>
290
291<dd>
292</dd>
293
294<dd> </dd>
295<dl class="dl-horizontal">
296<dt>memory_info</dt>
297<dd>The MemoryInfo structure.  </dd>
298</dl>
299<h2><a href="../../api/MagickCore/memory_8c.html" id="RelinquishAlignedMemory">RelinquishAlignedMemory</a></h2>
300
301<p>RelinquishAlignedMemory() frees memory acquired with AcquireAlignedMemory() or reuse.</p>
302
303<p>The format of the RelinquishAlignedMemory method is:</p>
304
305<pre class="text">
306void *RelinquishAlignedMemory(void *memory)
307</pre>
308
309<p>A description of each parameter follows:</p>
310
311<dd>
312</dd>
313
314<dd> </dd>
315<dl class="dl-horizontal">
316<dt>memory</dt>
317<dd>A pointer to a block of memory to free for reuse. </dd>
318
319<dd>  </dd>
320</dl>
321<h2><a href="../../api/MagickCore/memory_8c.html" id="RelinquishMagickMemory">RelinquishMagickMemory</a></h2>
322
323<p>RelinquishMagickMemory() frees memory acquired with AcquireMagickMemory() or AcquireQuantumMemory() for reuse.</p>
324
325<p>The format of the RelinquishMagickMemory method is:</p>
326
327<pre class="text">
328void *RelinquishMagickMemory(void *memory)
329</pre>
330
331<p>A description of each parameter follows:</p>
332
333<dd>
334</dd>
335
336<dd> </dd>
337<dl class="dl-horizontal">
338<dt>memory</dt>
339<dd>A pointer to a block of memory to free for reuse. </dd>
340
341<dd>  </dd>
342</dl>
343<h2><a href="../../api/MagickCore/memory_8c.html" id="RelinquishVirtualMemory">RelinquishVirtualMemory</a></h2>
344
345<p>RelinquishVirtualMemory() frees memory acquired with AcquireVirtualMemory().</p>
346
347<p>The format of the RelinquishVirtualMemory method is:</p>
348
349<pre class="text">
350MemoryInfo *RelinquishVirtualMemory(MemoryInfo *memory_info)
351</pre>
352
353<p>A description of each parameter follows:</p>
354
355<dd>
356</dd>
357
358<dd> </dd>
359<dl class="dl-horizontal">
360<dt>memory_info</dt>
361<dd>A pointer to a block of memory to free for reuse. </dd>
362
363<dd>  </dd>
364</dl>
365<h2><a href="../../api/MagickCore/memory_8c.html" id="ResetMagickMemory">ResetMagickMemory</a></h2>
366
367<p>ResetMagickMemory() fills the first size bytes of the memory area pointed to by memory with the constant byte c.</p>
368
369<p>The format of the ResetMagickMemory method is:</p>
370
371<pre class="text">
372void *ResetMagickMemory(void *memory,int byte,const size_t size)
373</pre>
374
375<p>A description of each parameter follows:</p>
376
377<dd>
378</dd>
379
380<dd> </dd>
381<dl class="dl-horizontal">
382<dt>memory</dt>
383<dd>a pointer to a memory allocation. </dd>
384
385<dd> </dd>
386<dt>byte</dt>
387<dd>set the memory to this value. </dd>
388
389<dd> </dd>
390<dt>size</dt>
391<dd>size of the memory to reset. </dd>
392
393<dd>  </dd>
394</dl>
395<h2><a href="../../api/MagickCore/memory_8c.html" id="ResizeMagickMemory">ResizeMagickMemory</a></h2>
396
397<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>
398
399<p>The format of the ResizeMagickMemory method is:</p>
400
401<pre class="text">
402void *ResizeMagickMemory(void *memory,const size_t size)
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>memory</dt>
413<dd>A pointer to a memory allocation. </dd>
414
415<dd> </dd>
416<dt>size</dt>
417<dd>the new size of the allocated memory. </dd>
418
419<dd>  </dd>
420</dl>
421<h2><a href="../../api/MagickCore/memory_8c.html" id="ResizeQuantumMemory">ResizeQuantumMemory</a></h2>
422
423<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>
424
425<p>The format of the ResizeQuantumMemory method is:</p>
426
427<pre class="text">
428void *ResizeQuantumMemory(void *memory,const size_t count,
429  const size_t quantum)
430</pre>
431
432<p>A description of each parameter follows:</p>
433
434<dd>
435</dd>
436
437<dd> </dd>
438<dl class="dl-horizontal">
439<dt>memory</dt>
440<dd>A pointer to a memory allocation. </dd>
441
442<dd> </dd>
443<dt>count</dt>
444<dd>the number of objects to allocate contiguously. </dd>
445
446<dd> </dd>
447<dt>quantum</dt>
448<dd>the size (in bytes) of each object. </dd>
449
450<dd>  </dd>
451</dl>
452<h2><a href="../../api/MagickCore/memory_8c.html" id="SetMagickAlignedMemoryMethods">SetMagickAlignedMemoryMethods</a></h2>
453
454<p>SetMagickAlignedMemoryMethods() sets the methods to acquire and relinquish aligned memory.</p>
455
456<p>The format of the SetMagickAlignedMemoryMethods() method is:</p>
457
458<pre class="text">
459SetMagickAlignedMemoryMethods(
460  AcquireAlignedMemoryHandler acquire_aligned_memory_handler,
461  RelinquishAlignedMemoryHandler relinquish_aligned_memory_handler)
462</pre>
463
464<p>A description of each parameter follows:</p>
465
466<dd>
467</dd>
468
469<dd> </dd>
470<dl class="dl-horizontal">
471<dt>acquire_memory_handler</dt>
472<dd>method to acquire aligned memory. </dd>
473
474<dd> </dd>
475<dt>relinquish_aligned_memory_handler</dt>
476<dd>method to relinquish aligned memory. </dd>
477
478<dd>  </dd>
479</dl>
480<h2><a href="../../api/MagickCore/memory_8c.html" id="SetMagickMemoryMethods">SetMagickMemoryMethods</a></h2>
481
482<p>SetMagickMemoryMethods() sets the methods to acquire, resize, and destroy memory. Your custom memory methods must be set prior to the MagickCoreGenesis() method.</p>
483
484<p>The format of the SetMagickMemoryMethods() method is:</p>
485
486<pre class="text">
487SetMagickMemoryMethods(AcquireMemoryHandler acquire_memory_handler,
488  ResizeMemoryHandler resize_memory_handler,
489  DestroyMemoryHandler destroy_memory_handler)
490</pre>
491
492<p>A description of each parameter follows:</p>
493
494<dd>
495</dd>
496
497<dd> </dd>
498<dl class="dl-horizontal">
499<dt>acquire_memory_handler</dt>
500<dd>method to acquire memory (e.g. malloc). </dd>
501
502<dd> </dd>
503<dt>resize_memory_handler</dt>
504<dd>method to resize memory (e.g. realloc). </dd>
505
506<dd> </dd>
507<dt>destroy_memory_handler</dt>
508<dd>method to destroy memory (e.g. free). </dd>
509
510<dd>  </dd>
511</dl>
512</div>
513    </div>
514  </main><!-- /.container -->
515  <footer class="magick-footer">
516    <p><a href="../../www/security-policy.html">Security</a> •
517    <a href="../../www/architecture.html">Architecture</a>
518
519    <a href="memory.html#"><img class="d-inline" id="wand" alt="And Now a Touch of Magick" width="16" height="16" src="../../images/wand.ico"/></a>
520
521    <a href="../../www/links.html">Related</a> •
522     <a href="../../www/sitemap.html">Sitemap</a>
523    <br/>
524    <a href="../../www/support.html">Donate</a> •
525    <a href="http://pgp.mit.edu/pks/lookup?op=get&amp;search=0x89AB63D48277377A">Public Key</a> •
526    <a href="../../www/contact.html">Contact Us</a>
527    <br/>
528    <small>© 1999-2020 ImageMagick Studio LLC</small></p>
529  </footer>
530
531  <!-- Javascript assets -->
532  <script src="../assets/magick.js" crossorigin="anonymous"></script>
533  <script>window.jQuery || document.write('<script src="https://localhost/ajax/libs/jquery/3.4.1/jquery.min.js"><\/script>')</script>
534</body>
535</html>
536<!-- Magick Cache 29th December 2019 14:22 -->