MagickCore  7.0.3
resource.c
Go to the documentation of this file.
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % %
4 % %
5 % %
6 % RRRR EEEEE SSSSS OOO U U RRRR CCCC EEEEE %
7 % R R E SS O O U U R R C E %
8 % RRRR EEE SSS O O U U RRRR C EEE %
9 % R R E SS O O U U R R C E %
10 % R R EEEEE SSSSS OOO UUU R R CCCC EEEEE %
11 % %
12 % %
13 % Get/Set MagickCore Resources %
14 % %
15 % Software Design %
16 % Cristy %
17 % September 2002 %
18 % %
19 % %
20 % Copyright 1999-2019 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
22 % %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
25 % %
26 % https://imagemagick.org/script/license.php %
27 % %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
33 % %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 %
36 %
37 */
38 
39 /*
40  Include declarations.
41 */
42 #include "MagickCore/studio.h"
43 #include "MagickCore/cache.h"
45 #include "MagickCore/configure.h"
46 #include "MagickCore/exception.h"
48 #include "MagickCore/linked-list.h"
49 #include "MagickCore/log.h"
50 #include "MagickCore/image.h"
52 #include "MagickCore/memory_.h"
54 #include "MagickCore/option.h"
55 #include "MagickCore/policy.h"
56 #include "MagickCore/random_.h"
57 #include "MagickCore/registry.h"
58 #include "MagickCore/resource_.h"
60 #include "MagickCore/semaphore.h"
62 #include "MagickCore/string_.h"
64 #include "MagickCore/splay-tree.h"
66 #include "MagickCore/token.h"
67 #include "MagickCore/utility.h"
69 
70 /*
71  Define declarations.
72 */
73 #define MagickPathTemplate "XXXXXXXXXXXX"
74 #define NumberOfResourceTypes \
75  (sizeof(resource_semaphore)/sizeof(*resource_semaphore))
76 
77 /*
78  Typedef declarations.
79 */
80 typedef struct _ResourceInfo
81 {
84  height,
86  area,
87  memory,
88  map,
89  disk,
90  file,
91  thread,
92  throttle,
93  time;
94 
99  area_limit,
100  memory_limit,
101  map_limit,
102  disk_limit,
103  file_limit,
104  thread_limit,
106  time_limit;
107 } ResourceInfo;
108 
109 /*
110  Global declarations.
111 */
112 static RandomInfo
113  *random_info = (RandomInfo *) NULL;
114 
115 static ResourceInfo
117  {
118  MagickULLConstant(0), /* initial width */
119  MagickULLConstant(0), /* initial height */
120  MagickULLConstant(0), /* initial list length */
121  MagickULLConstant(0), /* initial area */
122  MagickULLConstant(0), /* initial memory */
123  MagickULLConstant(0), /* initial map */
124  MagickULLConstant(0), /* initial disk */
125  MagickULLConstant(0), /* initial file */
126  MagickULLConstant(0), /* initial thread */
127  MagickULLConstant(0), /* initial throttle */
128  MagickULLConstant(0), /* initial time */
129  (INT_MAX/(5*sizeof(Quantum))), /* width limit */
130  (INT_MAX/(5*sizeof(Quantum))), /* height limit */
131  MagickResourceInfinity, /* list length limit */
132  MagickULLConstant(3072)*1024*1024, /* area limit */
133  MagickULLConstant(1536)*1024*1024, /* memory limit */
134  MagickULLConstant(3072)*1024*1024, /* map limit */
135  MagickResourceInfinity, /* disk limit */
136  MagickULLConstant(768), /* file limit */
137  MagickULLConstant(1), /* thread limit */
138  MagickULLConstant(0), /* throttle limit */
139  MagickResourceInfinity /* time limit */
140  };
141 
142 static SemaphoreInfo
144  (SemaphoreInfo *) NULL,
145  (SemaphoreInfo *) NULL,
146  (SemaphoreInfo *) NULL,
147  (SemaphoreInfo *) NULL,
148  (SemaphoreInfo *) NULL,
149  (SemaphoreInfo *) NULL,
150  (SemaphoreInfo *) NULL,
151  (SemaphoreInfo *) NULL,
152  (SemaphoreInfo *) NULL,
153  (SemaphoreInfo *) NULL,
154  (SemaphoreInfo *) NULL,
155  (SemaphoreInfo *) NULL
156  };
157 
158 static SplayTreeInfo
160 
161 /*
162 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
163 % %
164 % %
165 % %
166 % A c q u i r e M a g i c k R e s o u r c e %
167 % %
168 % %
169 % %
170 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
171 %
172 % AcquireMagickResource() acquires resources of the specified type.
173 % MagickFalse is returned if the specified resource is exhausted otherwise
174 % MagickTrue.
175 %
176 % The format of the AcquireMagickResource() method is:
177 %
178 % MagickBooleanType AcquireMagickResource(const ResourceType type,
179 % const MagickSizeType size)
180 %
181 % A description of each parameter follows:
182 %
183 % o type: the type of resource.
184 %
185 % o size: the number of bytes needed from for this resource.
186 %
187 */
189  const MagickSizeType size)
190 {
192  bi,
193  status;
194 
196  current,
197  request;
198 
200  limit;
201 
202  request=(MagickOffsetType) size;
203  if (request < 0)
204  return(MagickFalse);
205  limit=0;
206  current=0;
207  bi=MagickFalse;
208  status=MagickFalse;
209  switch (type)
210  {
211  case DiskResource:
212  case FileResource:
213  case MapResource:
214  case MemoryResource:
215  case TimeResource:
216  {
217  if (resource_semaphore[type] == (SemaphoreInfo *) NULL)
220  break;
221  }
222  default: ;
223  }
224  switch (type)
225  {
226  case AreaResource:
227  {
228  bi=MagickTrue;
229  resource_info.area=request;
231  if ((limit == MagickResourceInfinity) || (size < limit))
232  status=MagickTrue;
233  break;
234  }
235  case DiskResource:
236  {
237  bi=MagickTrue;
239  if ((resource_info.disk+request) > resource_info.disk)
240  {
241  resource_info.disk+=request;
242  if ((limit == MagickResourceInfinity) ||
243  (resource_info.disk < (MagickOffsetType) limit))
244  status=MagickTrue;
245  else
246  resource_info.disk-=request;
247  }
248  current=resource_info.disk;
249  break;
250  }
251  case FileResource:
252  {
254  if ((resource_info.file+request) > resource_info.file)
255  {
256  resource_info.file+=request;
257  if ((limit == MagickResourceInfinity) ||
258  (resource_info.file < (MagickOffsetType) limit))
259  status=MagickTrue;
260  }
261  current=resource_info.file;
262  break;
263  }
264  case HeightResource:
265  {
266  bi=MagickTrue;
267  resource_info.height=request;
269  if ((limit == MagickResourceInfinity) || (size < limit))
270  status=MagickTrue;
271  break;
272  }
273  case ListLengthResource:
274  {
275  resource_info.list_length=request;
277  if ((limit == MagickResourceInfinity) || (size < limit))
278  status=MagickTrue;
279  break;
280  }
281  case MapResource:
282  {
283  bi=MagickTrue;
284  limit=resource_info.map_limit;
285  if ((resource_info.map+request) > resource_info.map)
286  {
287  resource_info.map+=request;
288  if ((limit == MagickResourceInfinity) ||
289  (resource_info.map < (MagickOffsetType) limit))
290  status=MagickTrue;
291  else
292  resource_info.map-=request;
293  }
294  current=resource_info.map;
295  break;
296  }
297  case MemoryResource:
298  {
299  bi=MagickTrue;
301  if ((resource_info.memory+request) > resource_info.memory)
302  {
303  resource_info.memory+=request;
304  if ((limit == MagickResourceInfinity) ||
306  status=MagickTrue;
307  else
308  resource_info.memory-=request;
309  }
310  current=resource_info.memory;
311  break;
312  }
313  case ThreadResource:
314  {
316  if ((limit == MagickResourceInfinity) ||
318  status=MagickTrue;
319  break;
320  }
321  case ThrottleResource:
322  {
324  if ((limit == MagickResourceInfinity) ||
326  status=MagickTrue;
327  break;
328  }
329  case TimeResource:
330  {
332  if ((resource_info.time+request) > resource_info.time)
333  {
334  resource_info.time+=request;
335  if ((limit == MagickResourceInfinity) ||
336  (resource_info.time < (MagickOffsetType) limit))
337  status=MagickTrue;
338  else
339  resource_info.time-=request;
340  }
341  current=resource_info.time;
342  break;
343  }
344  case WidthResource:
345  {
346  bi=MagickTrue;
347  resource_info.width=request;
349  if ((limit == MagickResourceInfinity) || (size < limit))
350  status=MagickTrue;
351  break;
352  }
353  default:
354  {
355  current=0;
356  break;
357  }
358  }
359  switch (type)
360  {
361  case DiskResource:
362  case FileResource:
363  case MapResource:
364  case MemoryResource:
365  case TimeResource:
366  {
368  break;
369  }
370  default: ;
371  }
372  if (IsEventLogging() != MagickFalse)
373  {
374  char
375  resource_current[MagickFormatExtent],
376  resource_limit[MagickFormatExtent],
377  resource_request[MagickFormatExtent];
378 
379  (void) FormatMagickSize(size,bi,(bi != MagickFalse) ? "B" :
380  (const char *) NULL,MagickFormatExtent,resource_request);
381  (void) FormatMagickSize((MagickSizeType) current,bi,(bi != MagickFalse) ?
382  "B" : (const char *) NULL,MagickFormatExtent,resource_current);
383  (void) FormatMagickSize(limit,bi,(bi != MagickFalse) ? "B" :
384  (const char *) NULL,MagickFormatExtent,resource_limit);
385  (void) LogMagickEvent(ResourceEvent,GetMagickModule(),"%s: %s/%s/%s",
387  resource_request,resource_current,resource_limit);
388  }
389  return(status);
390 }
391 
392 /*
393 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
394 % %
395 % %
396 % %
397 + A s y n c h r o n o u s R e s o u r c e C o m p o n e n t T e r m i n u s %
398 % %
399 % %
400 % %
401 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
402 %
403 % AsynchronousResourceComponentTerminus() destroys the resource environment.
404 % It differs from ResourceComponentTerminus() in that it can be called from a
405 % asynchronous signal handler.
406 %
407 % The format of the ResourceComponentTerminus() method is:
408 %
409 % ResourceComponentTerminus(void)
410 %
411 */
413 {
414  const char
415  *path;
416 
417  if (temporary_resources == (SplayTreeInfo *) NULL)
418  return;
419  /*
420  Remove any lingering temporary files.
421  */
423  path=(const char *) GetNextKeyInSplayTree(temporary_resources);
424  while (path != (const char *) NULL)
425  {
426  (void) ShredFile(path);
427  path=(const char *) GetNextKeyInSplayTree(temporary_resources);
428  }
429 }
430 
431 /*
432 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
433 % %
434 % %
435 % %
436 % A c q u i r e U n i q u e F i l e R e s o u r c e %
437 % %
438 % %
439 % %
440 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
441 %
442 % AcquireUniqueFileResource() returns a unique file name, and returns a file
443 % descriptor for the file open for reading and writing.
444 %
445 % The format of the AcquireUniqueFileResource() method is:
446 %
447 % int AcquireUniqueFileResource(char *path)
448 %
449 % A description of each parameter follows:
450 %
451 % o path: Specifies a pointer to an array of characters. The unique path
452 % name is returned in this array.
453 %
454 */
455 
456 static void *DestroyTemporaryResources(void *temporary_resource)
457 {
458  (void) ShredFile((char *) temporary_resource);
459  temporary_resource=DestroyString((char *) temporary_resource);
460  return((void *) NULL);
461 }
462 
464 {
465  char
466  *directory,
467  *value;
468 
470  *exception;
471 
473  status;
474 
475  struct stat
476  attributes;
477 
478  (void) FormatLocaleString(path,MagickPathExtent,"magick-%.20g"
479  MagickPathTemplate,(double) getpid());
480  exception=AcquireExceptionInfo();
481  directory=(char *) GetImageRegistry(StringRegistryType,"temporary-path",
482  exception);
483  exception=DestroyExceptionInfo(exception);
484  if (directory == (char *) NULL)
485  directory=GetEnvironmentValue("MAGICK_TEMPORARY_PATH");
486  if (directory == (char *) NULL)
487  directory=GetEnvironmentValue("MAGICK_TMPDIR");
488  if (directory == (char *) NULL)
489  directory=GetEnvironmentValue("TMPDIR");
490 #if defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__OS2__) || defined(__CYGWIN__)
491  if (directory == (char *) NULL)
492  directory=GetEnvironmentValue("TMP");
493  if (directory == (char *) NULL)
494  directory=GetEnvironmentValue("TEMP");
495 #endif
496 #if defined(__VMS)
497  if (directory == (char *) NULL)
498  directory=GetEnvironmentValue("MTMPDIR");
499 #endif
500 #if defined(P_tmpdir)
501  if (directory == (char *) NULL)
502  directory=ConstantString(P_tmpdir);
503 #endif
504  if (directory == (char *) NULL)
505  return(MagickTrue);
506  value=GetPolicyValue("resource:temporary-path");
507  if (value != (char *) NULL)
508  {
509  (void) CloneString(&directory,value);
510  value=DestroyString(value);
511  }
512  if (strlen(directory) > (MagickPathExtent-25))
513  {
514  directory=DestroyString(directory);
515  return(MagickFalse);
516  }
517  status=GetPathAttributes(directory,&attributes);
518  if ((status == MagickFalse) || !S_ISDIR(attributes.st_mode))
519  {
520  directory=DestroyString(directory);
521  return(MagickFalse);
522  }
523  if (directory[strlen(directory)-1] == *DirectorySeparator)
525  "%smagick-%.20g" MagickPathTemplate,directory,(double) getpid());
526  else
528  "%s%smagick-%.20g" MagickPathTemplate,directory,DirectorySeparator,
529  (double) getpid());
530  directory=DestroyString(directory);
531 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
532  {
533  register char
534  *p;
535 
536  /*
537  Ghostscript does not like backslashes so we need to replace them. The
538  forward slash also works under Windows.
539  */
540  for (p=(path[1] == *DirectorySeparator ? path+2 : path); *p != '\0'; p++)
541  if (*p == *DirectorySeparator)
542  *p='/';
543  }
544 #endif
545  return(MagickTrue);
546 }
547 
549 {
550 #if !defined(O_NOFOLLOW)
551 #define O_NOFOLLOW 0
552 #endif
553 #if !defined(TMP_MAX)
554 # define TMP_MAX 238328
555 #endif
556 
557  int
558  c,
559  file;
560 
561  register char
562  *p;
563 
564  register ssize_t
565  i;
566 
567  static const char
568  portable_filename[65] =
569  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";
570 
571  StringInfo
572  *key;
573 
574  unsigned char
575  *datum;
576 
577  assert(path != (char *) NULL);
579  if (random_info == (RandomInfo *) NULL)
580  {
583  LockSemaphoreInfo(resource_semaphore[FileResource]);
584  if (random_info == (RandomInfo *) NULL)
587  }
588  file=(-1);
589  for (i=0; i < (ssize_t) TMP_MAX; i++)
590  {
591  register ssize_t
592  j;
593 
594  /*
595  Get temporary pathname.
596  */
597  (void) GetPathTemplate(path);
598  key=GetRandomKey(random_info,6);
599  p=path+strlen(path)-strlen(MagickPathTemplate);
600  datum=GetStringInfoDatum(key);
601  for (j=0; j < (ssize_t) GetStringInfoLength(key); j++)
602  {
603  c=(int) (datum[j] & 0x3f);
604  *p++=portable_filename[c];
605  }
606  key=DestroyStringInfo(key);
607 #if defined(MAGICKCORE_HAVE_MKSTEMP)
608  file=mkstemp(path);
609  if (file != -1)
610  {
611 #if defined(MAGICKCORE_HAVE_FCHMOD)
612  (void) fchmod(file,0600);
613 #endif
614 #if defined(__OS2__)
615  setmode(file,O_BINARY);
616 #endif
617  break;
618  }
619 #endif
621  p=path+strlen(path)-strlen(MagickPathTemplate);
622  datum=GetStringInfoDatum(key);
623  for (j=0; j < (ssize_t) GetStringInfoLength(key); j++)
624  {
625  c=(int) (datum[j] & 0x3f);
626  *p++=portable_filename[c];
627  }
628  key=DestroyStringInfo(key);
629  file=open_utf8(path,O_RDWR | O_CREAT | O_EXCL | O_BINARY | O_NOFOLLOW,
630  S_MODE);
631  if ((file >= 0) || (errno != EEXIST))
632  break;
633  }
634  (void) LogMagickEvent(ResourceEvent,GetMagickModule(),"%s",path);
635  if (file == -1)
636  return(file);
639  LockSemaphoreInfo(resource_semaphore[FileResource]);
640  if (temporary_resources == (SplayTreeInfo *) NULL)
642  DestroyTemporaryResources,(void *(*)(void *)) NULL);
645  (const void *) NULL);
646  return(file);
647 }
648 
649 /*
650 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
651 % %
652 % %
653 % %
654 % G e t M a g i c k R e s o u r c e %
655 % %
656 % %
657 % %
658 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
659 %
660 % GetMagickResource() returns the specified resource.
661 %
662 % The format of the GetMagickResource() method is:
663 %
664 % MagickSizeType GetMagickResource(const ResourceType type)
665 %
666 % A description of each parameter follows:
667 %
668 % o type: the type of resource.
669 %
670 */
672 {
674  resource;
675 
676  resource=0;
677  switch (type)
678  {
679  case DiskResource:
680  case FileResource:
681  case MapResource:
682  case MemoryResource:
683  case TimeResource:
684  {
685  if (resource_semaphore[type] == (SemaphoreInfo *) NULL)
688  break;
689  }
690  default: ;
691  }
692  switch (type)
693  {
694  case AreaResource:
695  {
696  resource=(MagickSizeType) resource_info.area;
697  break;
698  }
699  case DiskResource:
700  {
701  resource=(MagickSizeType) resource_info.disk;
702  break;
703  }
704  case FileResource:
705  {
706  resource=(MagickSizeType) resource_info.file;
707  break;
708  }
709  case HeightResource:
710  {
712  break;
713  }
714  case ListLengthResource:
715  {
717  break;
718  }
719  case MapResource:
720  {
721  resource=(MagickSizeType) resource_info.map;
722  break;
723  }
724  case MemoryResource:
725  {
727  break;
728  }
729  case TimeResource:
730  {
731  resource=(MagickSizeType) resource_info.time;
732  break;
733  }
734  case ThreadResource:
735  {
737  break;
738  }
739  case ThrottleResource:
740  {
742  break;
743  }
744  case WidthResource:
745  {
747  break;
748  }
749  default:
750  break;
751  }
752  switch (type)
753  {
754  case DiskResource:
755  case FileResource:
756  case MapResource:
757  case MemoryResource:
758  case TimeResource:
759  {
761  break;
762  }
763  default: ;
764  }
765  return(resource);
766 }
767 
768 /*
769 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
770 % %
771 % %
772 % %
773 % G e t M a g i c k R e s o u r c e L i m i t %
774 % %
775 % %
776 % %
777 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
778 %
779 % GetMagickResourceLimit() returns the specified resource limit.
780 %
781 % The format of the GetMagickResourceLimit() method is:
782 %
783 % MagickSizeType GetMagickResourceLimit(const ResourceType type)
784 %
785 % A description of each parameter follows:
786 %
787 % o type: the type of resource.
788 %
789 */
791 {
793  resource;
794 
795  resource=0;
796  if (resource_semaphore[type] == (SemaphoreInfo *) NULL)
799  switch (type)
800  {
801  case AreaResource:
802  {
803  resource=resource_info.area_limit;
804  break;
805  }
806  case DiskResource:
807  {
808  resource=resource_info.disk_limit;
809  break;
810  }
811  case FileResource:
812  {
813  resource=resource_info.file_limit;
814  break;
815  }
816  case HeightResource:
817  {
818  resource=resource_info.height_limit;
819  break;
820  }
821  case ListLengthResource:
822  {
824  break;
825  }
826  case MemoryResource:
827  {
828  resource=resource_info.memory_limit;
829  break;
830  }
831  case MapResource:
832  {
833  resource=resource_info.map_limit;
834  break;
835  }
836  case ThreadResource:
837  {
838  resource=resource_info.thread_limit;
839  break;
840  }
841  case ThrottleResource:
842  {
843  resource=resource_info.throttle_limit;
844  break;
845  }
846  case TimeResource:
847  {
848  resource=resource_info.time_limit;
849  break;
850  }
851  case WidthResource:
852  {
853  resource=resource_info.width_limit;
854  break;
855  }
856  default:
857  break;
858  }
860  return(resource);
861 }
862 
863 /*
864 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
865 % %
866 % %
867 % %
868 % L i s t M a g i c k R e s o u r c e I n f o %
869 % %
870 % %
871 % %
872 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
873 %
874 % ListMagickResourceInfo() lists the resource info to a file.
875 %
876 % The format of the ListMagickResourceInfo method is:
877 %
878 % MagickBooleanType ListMagickResourceInfo(FILE *file,
879 % ExceptionInfo *exception)
880 %
881 % A description of each parameter follows.
882 %
883 % o file: An pointer to a FILE.
884 %
885 % o exception: return any errors or warnings in this structure.
886 %
887 */
889  ExceptionInfo *magick_unused(exception))
890 {
891  char
892  area_limit[MagickFormatExtent],
893  disk_limit[MagickFormatExtent],
894  height_limit[MagickFormatExtent],
895  list_length_limit[MagickFormatExtent],
896  map_limit[MagickFormatExtent],
897  memory_limit[MagickFormatExtent],
898  time_limit[MagickFormatExtent],
899  width_limit[MagickFormatExtent];
900 
901  magick_unreferenced(exception);
902 
903  if (file == (const FILE *) NULL)
904  file=stdout;
907  LockSemaphoreInfo(resource_semaphore[FileResource]);
909  MagickFormatExtent,width_limit);
911  MagickFormatExtent,height_limit);
913  MagickFormatExtent,area_limit);
914  (void) CopyMagickString(list_length_limit,"unlimited",MagickFormatExtent);
917  MagickFormatExtent,list_length_limit);
919  MagickFormatExtent,memory_limit);
921  MagickFormatExtent,map_limit);
922  (void) CopyMagickString(disk_limit,"unlimited",MagickFormatExtent);
925  MagickFormatExtent,disk_limit);
926  (void) CopyMagickString(time_limit,"unlimited",MagickFormatExtent);
928  (void) FormatLocaleString(time_limit,MagickFormatExtent,"%.20g",(double)
930  (void) FormatLocaleFile(file,"Resource limits:\n");
931  (void) FormatLocaleFile(file," Width: %s\n",width_limit);
932  (void) FormatLocaleFile(file," Height: %s\n",height_limit);
933  (void) FormatLocaleFile(file," Area: %s\n",area_limit);
934  (void) FormatLocaleFile(file," List length: %s\n",list_length_limit);
935  (void) FormatLocaleFile(file," Memory: %s\n",memory_limit);
936  (void) FormatLocaleFile(file," Map: %s\n",map_limit);
937  (void) FormatLocaleFile(file," Disk: %s\n",disk_limit);
938  (void) FormatLocaleFile(file," File: %.20g\n",(double) ((MagickOffsetType)
940  (void) FormatLocaleFile(file," Thread: %.20g\n",(double) ((MagickOffsetType)
942  (void) FormatLocaleFile(file," Throttle: %.20g\n",(double)
944  (void) FormatLocaleFile(file," Time: %s\n",time_limit);
945  (void) fflush(file);
947  return(MagickTrue);
948 }
949 
950 /*
951 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
952 % %
953 % %
954 % %
955 % R e l i n q u i s h M a g i c k R e s o u r c e %
956 % %
957 % %
958 % %
959 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
960 %
961 % RelinquishMagickResource() relinquishes resources of the specified type.
962 %
963 % The format of the RelinquishMagickResource() method is:
964 %
965 % void RelinquishMagickResource(const ResourceType type,
966 % const MagickSizeType size)
967 %
968 % A description of each parameter follows:
969 %
970 % o type: the type of resource.
971 %
972 % o size: the size of the resource.
973 %
974 */
976  const MagickSizeType size)
977 {
979  bi;
980 
982  current,
983  limit;
984 
985  bi=MagickFalse;
986  limit=0;
987  current=0;
988  switch (type)
989  {
990  case DiskResource:
991  case FileResource:
992  case MapResource:
993  case MemoryResource:
994  case TimeResource:
995  {
996  if (resource_semaphore[type] == (SemaphoreInfo *) NULL)
999  break;
1000  }
1001  default: ;
1002  }
1003  switch (type)
1004  {
1005  case DiskResource:
1006  {
1007  bi=MagickTrue;
1008  resource_info.disk-=size;
1009  current=(MagickSizeType) resource_info.disk;
1010  limit=resource_info.disk_limit;
1011  assert(resource_info.disk >= 0);
1012  break;
1013  }
1014  case FileResource:
1015  {
1016  resource_info.file-=size;
1017  current=(MagickSizeType) resource_info.file;
1018  limit=resource_info.file_limit;
1019  assert(resource_info.file >= 0);
1020  break;
1021  }
1022  case MapResource:
1023  {
1024  bi=MagickTrue;
1025  resource_info.map-=size;
1026  current=(MagickSizeType) resource_info.map;
1027  limit=resource_info.map_limit;
1028  assert(resource_info.map >= 0);
1029  break;
1030  }
1031  case MemoryResource:
1032  {
1033  bi=MagickTrue;
1034  resource_info.memory-=size;
1037  assert(resource_info.memory >= 0);
1038  break;
1039  }
1040  case TimeResource:
1041  {
1042  bi=MagickTrue;
1043  resource_info.time-=size;
1044  current=(MagickSizeType) resource_info.time;
1045  limit=resource_info.time_limit;
1046  assert(resource_info.time >= 0);
1047  break;
1048  }
1049  default:
1050  {
1051  current=0;
1052  break;
1053  }
1054  }
1055  switch (type)
1056  {
1057  case DiskResource:
1058  case FileResource:
1059  case MapResource:
1060  case MemoryResource:
1061  case TimeResource:
1062  {
1064  break;
1065  }
1066  default: ;
1067  }
1068  if (IsEventLogging() != MagickFalse)
1069  {
1070  char
1071  resource_current[MagickFormatExtent],
1072  resource_limit[MagickFormatExtent],
1073  resource_request[MagickFormatExtent];
1074 
1075  (void) FormatMagickSize(size,bi,(bi != MagickFalse) ? "B" :
1076  (const char *) NULL,MagickFormatExtent,resource_request);
1077  (void) FormatMagickSize(current,bi,(bi != MagickFalse) ? "B" :
1078  (const char *) NULL,MagickFormatExtent,resource_current);
1079  (void) FormatMagickSize(limit,bi,(bi != MagickFalse) ? "B" :
1080  (const char *) NULL,MagickFormatExtent,resource_limit);
1081  (void) LogMagickEvent(ResourceEvent,GetMagickModule(),"%s: %s/%s/%s",
1083  resource_request,resource_current,resource_limit);
1084  }
1085 }
1086 
1087 /*
1088 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1089 % %
1090 % %
1091 % %
1092 % R e l i n q u i s h U n i q u e F i l e R e s o u r c e %
1093 % %
1094 % %
1095 % %
1096 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1097 %
1098 % RelinquishUniqueFileResource() relinquishes a unique file resource.
1099 %
1100 % The format of the RelinquishUniqueFileResource() method is:
1101 %
1102 % MagickBooleanType RelinquishUniqueFileResource(const char *path)
1103 %
1104 % A description of each parameter follows:
1105 %
1106 % o name: the name of the temporary resource.
1107 %
1108 */
1110 {
1111  char
1112  cache_path[MagickPathExtent];
1113 
1115  status;
1116 
1117  assert(path != (const char *) NULL);
1118  status=MagickFalse;
1119  (void) LogMagickEvent(ResourceEvent,GetMagickModule(),"%s",path);
1122  LockSemaphoreInfo(resource_semaphore[FileResource]);
1123  if (temporary_resources != (SplayTreeInfo *) NULL)
1124  status=DeleteNodeFromSplayTree(temporary_resources,(const void *) path);
1125  UnlockSemaphoreInfo(resource_semaphore[FileResource]);
1126  (void) CopyMagickString(cache_path,path,MagickPathExtent);
1127  AppendImageFormat("cache",cache_path);
1128  if (access_utf8(cache_path,F_OK) == 0)
1129  (void) ShredFile(cache_path);
1130  if (status == MagickFalse)
1131  status=ShredFile(path);
1132  return(status);
1133 }
1134 
1135 /*
1136 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1137 % %
1138 % %
1139 % %
1140 + R e s o u r c e C o m p o n e n t G e n e s i s %
1141 % %
1142 % %
1143 % %
1144 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1145 %
1146 % ResourceComponentGenesis() instantiates the resource component.
1147 %
1148 % The format of the ResourceComponentGenesis method is:
1149 %
1150 % MagickBooleanType ResourceComponentGenesis(void)
1151 %
1152 */
1153 
1155 {
1156  char
1157  *limit;
1158 
1160  memory;
1161 
1162  register ssize_t
1163  i;
1164 
1165  ssize_t
1166  files,
1167  pages,
1168  pagesize;
1169 
1170  /*
1171  Set Magick resource limits.
1172  */
1173  for (i=0; i < (ssize_t) NumberOfResourceTypes; i++)
1174  if (resource_semaphore[i] == (SemaphoreInfo *) NULL)
1177  limit=GetEnvironmentValue("MAGICK_WIDTH_LIMIT");
1178  if (limit != (char *) NULL)
1179  {
1181  100.0));
1182  limit=DestroyString(limit);
1183  }
1185  limit=GetEnvironmentValue("MAGICK_HEIGHT_LIMIT");
1186  if (limit != (char *) NULL)
1187  {
1189  limit,100.0));
1190  limit=DestroyString(limit);
1191  }
1192  pagesize=GetMagickPageSize();
1193  pages=(-1);
1194 #if defined(MAGICKCORE_HAVE_SYSCONF) && defined(_SC_PHYS_PAGES)
1195  pages=(ssize_t) sysconf(_SC_PHYS_PAGES);
1196 #endif
1197  memory=(MagickSizeType) pages*pagesize;
1198  if ((pagesize <= 0) || (pages <= 0))
1199  memory=2048UL*1024UL*1024UL;
1200 #if defined(PixelCacheThreshold)
1201  memory=PixelCacheThreshold;
1202 #endif
1203  (void) SetMagickResourceLimit(AreaResource,2*memory);
1204  limit=GetEnvironmentValue("MAGICK_AREA_LIMIT");
1205  if (limit != (char *) NULL)
1206  {
1208  100.0));
1209  limit=DestroyString(limit);
1210  }
1211  (void) SetMagickResourceLimit(MemoryResource,memory);
1212  limit=GetEnvironmentValue("MAGICK_MEMORY_LIMIT");
1213  if (limit != (char *) NULL)
1214  {
1216  limit,100.0));
1217  limit=DestroyString(limit);
1218  }
1219  (void) SetMagickResourceLimit(MapResource,2*memory);
1220  limit=GetEnvironmentValue("MAGICK_MAP_LIMIT");
1221  if (limit != (char *) NULL)
1222  {
1224  100.0));
1225  limit=DestroyString(limit);
1226  }
1228  limit=GetEnvironmentValue("MAGICK_DISK_LIMIT");
1229  if (limit != (char *) NULL)
1230  {
1232  100.0));
1233  limit=DestroyString(limit);
1234  }
1235  files=(-1);
1236 #if defined(MAGICKCORE_HAVE_SYSCONF) && defined(_SC_OPEN_MAX)
1237  files=(ssize_t) sysconf(_SC_OPEN_MAX);
1238 #endif
1239 #if defined(MAGICKCORE_HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE)
1240  if (files < 0)
1241  {
1242  struct rlimit
1243  resources;
1244 
1245  if (getrlimit(RLIMIT_NOFILE,&resources) != -1)
1246  files=(ssize_t) resources.rlim_cur;
1247  }
1248 #endif
1249 #if defined(MAGICKCORE_HAVE_GETDTABLESIZE) && defined(MAGICKCORE_POSIX_SUPPORT)
1250  if (files < 0)
1251  files=(ssize_t) getdtablesize();
1252 #endif
1253  if (files < 0)
1254  files=64;
1256  (3*files/4),64));
1257  limit=GetEnvironmentValue("MAGICK_FILE_LIMIT");
1258  if (limit != (char *) NULL)
1259  {
1261  100.0));
1262  limit=DestroyString(limit);
1263  }
1265  limit=GetEnvironmentValue("MAGICK_THREAD_LIMIT");
1266  if (limit != (char *) NULL)
1267  {
1269  limit,100.0));
1270  limit=DestroyString(limit);
1271  }
1273  limit=GetEnvironmentValue("MAGICK_THROTTLE_LIMIT");
1274  if (limit != (char *) NULL)
1275  {
1277  limit,100.0));
1278  limit=DestroyString(limit);
1279  }
1281  limit=GetEnvironmentValue("MAGICK_TIME_LIMIT");
1282  if (limit != (char *) NULL)
1283  {
1285  100.0));
1286  limit=DestroyString(limit);
1287  }
1289  limit=GetEnvironmentValue("MAGICK_LIST_LENGTH_LIMIT");
1290  if (limit != (char *) NULL)
1291  {
1293  StringToMagickSizeType(limit,100.0));
1294  limit=DestroyString(limit);
1295  }
1296  return(MagickTrue);
1297 }
1298 
1299 /*
1300 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1301 % %
1302 % %
1303 % %
1304 + R e s o u r c e C o m p o n e n t T e r m i n u s %
1305 % %
1306 % %
1307 % %
1308 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1309 %
1310 % ResourceComponentTerminus() destroys the resource component.
1311 %
1312 % The format of the ResourceComponentTerminus() method is:
1313 %
1314 % ResourceComponentTerminus(void)
1315 %
1316 */
1318 {
1319  register ssize_t
1320  i;
1321 
1322  for (i=0; i < (ssize_t) NumberOfResourceTypes; i++)
1323  if (resource_semaphore[i] == (SemaphoreInfo *) NULL)
1326  if (temporary_resources != (SplayTreeInfo *) NULL)
1328  if (random_info != (RandomInfo *) NULL)
1330  UnlockSemaphoreInfo(resource_semaphore[FileResource]);
1331  for (i=0; i < (ssize_t) NumberOfResourceTypes; i++)
1333 }
1334 
1335 /*
1336 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1337 % %
1338 % %
1339 % %
1340 % S e t M a g i c k R e s o u r c e L i m i t %
1341 % %
1342 % %
1343 % %
1344 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1345 %
1346 % SetMagickResourceLimit() sets the limit for a particular resource.
1347 %
1348 % The format of the SetMagickResourceLimit() method is:
1349 %
1350 % MagickBooleanType SetMagickResourceLimit(const ResourceType type,
1351 % const MagickSizeType limit)
1352 %
1353 % A description of each parameter follows:
1354 %
1355 % o type: the type of resource.
1356 %
1357 % o limit: the maximum limit for the resource.
1358 %
1359 */
1361  const MagickSizeType limit)
1362 {
1363  char
1364  *value;
1365 
1367  status;
1368 
1369  status=MagickTrue;
1370  value=(char *) NULL;
1371  if (resource_semaphore[type] == (SemaphoreInfo *) NULL)
1374  switch (type)
1375  {
1376  case AreaResource:
1377  {
1378  value=GetPolicyValue("resource:area");
1379  if (value == (char *) NULL)
1380  resource_info.area_limit=limit;
1381  else
1383  100.0));
1384  break;
1385  }
1386  case DiskResource:
1387  {
1388  value=GetPolicyValue("resource:disk");
1389  if (value == (char *) NULL)
1390  resource_info.disk_limit=limit;
1391  else
1393  100.0));
1394  break;
1395  }
1396  case FileResource:
1397  {
1398  value=GetPolicyValue("resource:file");
1399  if (value == (char *) NULL)
1400  resource_info.file_limit=limit;
1401  else
1403  100.0));
1404  break;
1405  }
1406  case HeightResource:
1407  {
1408  value=GetPolicyValue("resource:height");
1409  if (value == (char *) NULL)
1411  else
1413  value,100.0));
1415  SSIZE_MAX);
1416  break;
1417  }
1418  case ListLengthResource:
1419  {
1420  value=GetPolicyValue("resource:list-length");
1421  if (value == (char *) NULL)
1423  else
1425  StringToMagickSizeType(value,100.0));
1426  break;
1427  }
1428  case MapResource:
1429  {
1430  value=GetPolicyValue("resource:map");
1431  if (value == (char *) NULL)
1432  resource_info.map_limit=limit;
1433  else
1435  value,100.0));
1436  break;
1437  }
1438  case MemoryResource:
1439  {
1440  value=GetPolicyValue("resource:memory");
1441  if (value == (char *) NULL)
1443  else
1445  value,100.0));
1446  break;
1447  }
1448  case ThreadResource:
1449  {
1450  value=GetPolicyValue("resource:thread");
1451  if (value == (char *) NULL)
1453  else
1455  value,100.0));
1458  else
1459  if (resource_info.thread_limit == 0)
1461  break;
1462  }
1463  case ThrottleResource:
1464  {
1465  value=GetPolicyValue("resource:throttle");
1466  if (value == (char *) NULL)
1468  else
1470  value,100.0));
1471  break;
1472  }
1473  case TimeResource:
1474  {
1475  value=GetPolicyValue("resource:time");
1476  if (value == (char *) NULL)
1477  resource_info.time_limit=limit;
1478  else
1480  100.0));
1482  break;
1483  }
1484  case WidthResource:
1485  {
1486  value=GetPolicyValue("resource:width");
1487  if (value == (char *) NULL)
1488  resource_info.width_limit=limit;
1489  else
1491  100.0));
1493  SSIZE_MAX);
1494  break;
1495  }
1496  default:
1497  {
1498  status=MagickFalse;
1499  break;
1500  }
1501  }
1503  if (value != (char *) NULL)
1504  value=DestroyString(value);
1505  return(status);
1506 }
MagickExport ssize_t FormatMagickSize(const MagickSizeType size, const MagickBooleanType bi, const char *suffix, const size_t length, char *format)
Definition: string.c:1093
MagickPrivate MagickBooleanType ResourceComponentGenesis(void)
Definition: resource.c:1154
MagickOffsetType map
Definition: resource.c:83
MagickExport MagickBooleanType GetPathAttributes(const char *path, void *attributes)
Definition: utility.c:1165
MagickExport MagickBooleanType AddValueToSplayTree(SplayTreeInfo *splay_tree, const void *key, const void *value)
Definition: splay-tree.c:154
MagickExport void UnlockSemaphoreInfo(SemaphoreInfo *semaphore_info)
Definition: semaphore.c:450
MagickExport MagickBooleanType ListMagickResourceInfo(FILE *file, ExceptionInfo *magick_unused(exception))
Definition: resource.c:888
static void * DestroyTemporaryResources(void *temporary_resource)
Definition: resource.c:456
#define MagickULLConstant(c)
Definition: magick-type.h:36
struct _ResourceInfo ResourceInfo
MagickOffsetType file
Definition: resource.c:83
static size_t GetOpenMPMaximumThreads(void)
MagickOffsetType thread
Definition: resource.c:83
MagickSizeType height_limit
Definition: resource.c:96
static SemaphoreInfo * resource_semaphore[]
Definition: resource.c:143
MagickExport SemaphoreInfo * AcquireSemaphoreInfo(void)
Definition: semaphore.c:192
static ResourceInfo resource_info
Definition: resource.c:116
MagickSizeType map_limit
Definition: resource.c:96
MagickOffsetType memory
Definition: resource.c:83
MagickExport MagickBooleanType SetMagickResourceLimit(const ResourceType type, const MagickSizeType limit)
Definition: resource.c:1360
MagickOffsetType area
Definition: resource.c:83
#define S_ISDIR(mode)
Definition: studio.h:200
MagickSizeType area_limit
Definition: resource.c:96
MagickExport ExceptionInfo * AcquireExceptionInfo(void)
Definition: exception.c:115
MagickOffsetType time
Definition: resource.c:83
MagickExport ssize_t FormatLocaleString(char *magick_restrict string, const size_t length, const char *magick_restrict format,...)
Definition: locale.c:499
MagickExport void RelinquishMagickResource(const ResourceType type, const MagickSizeType size)
Definition: resource.c:975
#define O_BINARY
Definition: studio.h:325
MagickExport MagickBooleanType AcquireMagickResource(const ResourceType type, const MagickSizeType size)
Definition: resource.c:188
ssize_t MagickOffsetType
Definition: magick-type.h:129
MagickOffsetType disk
Definition: resource.c:83
MagickExport RandomInfo * DestroyRandomInfo(RandomInfo *random_info)
Definition: random.c:274
MagickExport void LockSemaphoreInfo(SemaphoreInfo *semaphore_info)
Definition: semaphore.c:293
MagickExport unsigned char * GetStringInfoDatum(const StringInfo *string_info)
Definition: string.c:1215
MagickSizeType memory_limit
Definition: resource.c:96
MagickExport ssize_t FormatLocaleFile(FILE *file, const char *magick_restrict format,...)
Definition: locale.c:404
MagickBooleanType
Definition: magick-type.h:158
#define DirectorySeparator
Definition: studio.h:259
MagickExport int AcquireUniqueFileResource(char *path)
Definition: resource.c:548
MagickPrivate ssize_t GetMagickPageSize(void)
Definition: utility.c:1122
MagickPrivate void AsynchronousResourceComponentTerminus(void)
MagickExport const char * CommandOptionToMnemonic(const CommandOption option, const ssize_t type)
Definition: option.c:2680
static SplayTreeInfo * temporary_resources
Definition: resource.c:159
MagickExport StringInfo * DestroyStringInfo(StringInfo *string_info)
Definition: string.c:850
MagickOffsetType list_length
Definition: resource.c:83
MagickSizeType time_limit
Definition: resource.c:96
MagickExport MagickBooleanType RelinquishUniqueFileResource(const char *path)
Definition: resource.c:1109
#define magick_unused(x)
MagickExport SplayTreeInfo * DestroySplayTree(SplayTreeInfo *splay_tree)
Definition: splay-tree.c:682
size_t MagickSizeType
Definition: magick-type.h:130
#define MagickPathExtent
MagickOffsetType width
Definition: resource.c:83
MagickExport MagickBooleanType IsEventLogging(void)
Definition: log.c:720
MagickExport SplayTreeInfo * NewSplayTree(int(*compare)(const void *, const void *), void *(*relinquish_key)(void *), void *(*relinquish_value)(void *))
Definition: splay-tree.c:1141
#define O_NOFOLLOW
MagickExport MagickBooleanType LogMagickEvent(const LogEventType type, const char *module, const char *function, const size_t line, const char *format,...)
Definition: log.c:1397
static int open_utf8(const char *path, int flags, mode_t mode)
MagickExport RandomInfo * AcquireRandomInfo(void)
Definition: random.c:164
MagickExport MagickSizeType GetMagickResourceLimit(const ResourceType type)
Definition: resource.c:790
MagickExport char * GetEnvironmentValue(const char *name)
Definition: string.c:1182
MagickExport size_t CopyMagickString(char *destination, const char *source, const size_t length)
Definition: string.c:755
MagickPrivate MagickBooleanType ShredFile(const char *)
Definition: utility.c:1809
#define S_MODE
Definition: studio.h:239
#define MagickMax(x, y)
Definition: image-private.h:26
MagickExport void AppendImageFormat(const char *format, char *filename)
Definition: utility.c:281
MagickPrivate void ResourceComponentTerminus(void)
Definition: resource.c:1317
ResourceType
Definition: resource_.h:25
MagickSizeType throttle_limit
Definition: resource.c:96
#define MagickFormatExtent
#define GetMagickModule()
Definition: log.h:28
MagickExport int CompareSplayTreeString(const void *target, const void *source)
Definition: splay-tree.c:412
MagickExport MagickSizeType GetMagickResource(const ResourceType type)
Definition: resource.c:671
#define MagickResourceInfinity
Definition: resource_.h:41
MagickExport const void * GetNextKeyInSplayTree(SplayTreeInfo *splay_tree)
Definition: splay-tree.c:769
unsigned short Quantum
Definition: magick-type.h:82
MagickExport char * DestroyString(char *string)
Definition: string.c:823
MagickExport void ActivateSemaphoreInfo(SemaphoreInfo **semaphore_info)
Definition: semaphore.c:97
MagickOffsetType throttle
Definition: resource.c:83
static MagickSizeType StringToMagickSizeType(const char *string, const double interval)
static int access_utf8(const char *path, int mode)
MagickSizeType list_length_limit
Definition: resource.c:96
MagickExport MagickBooleanType DeleteNodeFromSplayTree(SplayTreeInfo *splay_tree, const void *key)
Definition: splay-tree.c:603
#define MagickMin(x, y)
Definition: image-private.h:27
MagickExport char * GetPolicyValue(const char *name)
Definition: policy.c:506
MagickSizeType thread_limit
Definition: resource.c:96
MagickExport void ResetSplayTreeIterator(SplayTreeInfo *splay_tree)
Definition: splay-tree.c:1472
static RandomInfo * random_info
Definition: resource.c:113
MagickPrivate void ResetPixelCacheEpoch(void)
#define magick_unreferenced(x)
#define MagickPathTemplate
Definition: resource.c:73
MagickSizeType width_limit
Definition: resource.c:96
MagickExport void * GetImageRegistry(const RegistryType type, const char *key, ExceptionInfo *exception)
Definition: registry.c:187
MagickExport char * CloneString(char **destination, const char *source)
Definition: string.c:286
#define MagickPrivate
#define MagickExport
MagickOffsetType height
Definition: resource.c:83
MagickExport StringInfo * GetRandomKey(RandomInfo *random_info, const size_t length)
Definition: random.c:710
#define TMP_MAX
MagickSizeType file_limit
Definition: resource.c:96
MagickExport size_t GetStringInfoLength(const StringInfo *string_info)
Definition: string.c:1244
#define NumberOfResourceTypes
Definition: resource.c:74
MagickSizeType disk_limit
Definition: resource.c:96
MagickExport MagickBooleanType GetPathTemplate(char *path)
Definition: resource.c:463
MagickExport void RelinquishSemaphoreInfo(SemaphoreInfo **semaphore_info)
Definition: semaphore.c:351
MagickExport char * ConstantString(const char *source)
Definition: string.c:700
MagickExport ExceptionInfo * DestroyExceptionInfo(ExceptionInfo *exception)
Definition: exception.c:418