% September 2002 %
% %
% %
-% Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2017 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
% obtain a copy of the License at %
% %
-% http://www.imagemagick.org/script/license.php %
+% https://www.imagemagick.org/script/license.php %
% %
% Unless required by applicable law or agreed to in writing, software %
% distributed under the License is distributed on an "AS IS" BASIS, %
*/
#include "MagickCore/studio.h"
#include "MagickCore/cache.h"
+#include "MagickCore/cache-private.h"
#include "MagickCore/configure.h"
#include "MagickCore/exception.h"
#include "MagickCore/exception-private.h"
-#include "MagickCore/hashmap.h"
+#include "MagickCore/linked-list.h"
#include "MagickCore/log.h"
#include "MagickCore/image.h"
#include "MagickCore/image-private.h"
#include "MagickCore/utility.h"
#include "MagickCore/utility-private.h"
\f
+/*
+ Define declarations.
+*/
+#define MagickPathTemplate "XXXXXXXXXXXX"
+\f
/*
Typedef declarations.
*/
status=(resource_info.area_limit == MagickResourceInfinity) ||
(size < limit) ? MagickTrue : MagickFalse;
(void) FormatMagickSize((MagickSizeType) resource_info.area,MagickFalse,
- "B",MagickFormatExtent,resource_current);
- (void) FormatMagickSize(resource_info.area_limit,MagickFalse,"B",
+ "P",MagickFormatExtent,resource_current);
+ (void) FormatMagickSize(resource_info.area_limit,MagickFalse,"P",
MagickFormatExtent,resource_limit);
break;
}
struct stat
attributes;
- (void) FormatLocaleString(path,MagickPathExtent,"magick-%.20gXXXXXXXXXXXX",
- (double) getpid());
+ (void) FormatLocaleString(path,MagickPathExtent,"magick-%.20g"
+ MagickPathTemplate,(double) getpid());
exception=AcquireExceptionInfo();
directory=(char *) GetImageRegistry(StringRegistryType,"temporary-path",
exception);
#endif
if (directory == (char *) NULL)
return(MagickTrue);
- value=GetPolicyValue("temporary-path");
+ value=GetPolicyValue("resource:temporary-path");
if (value != (char *) NULL)
- (void) CloneString(&directory,value);
+ {
+ (void) CloneString(&directory,value);
+ value=DestroyString(value);
+ }
if (strlen(directory) > (MagickPathExtent-25))
{
directory=DestroyString(directory);
}
if (directory[strlen(directory)-1] == *DirectorySeparator)
(void) FormatLocaleString(path,MagickPathExtent,
- "%smagick-%.20gXXXXXXXXXXXX",directory,(double) getpid());
+ "%smagick-%.20g" MagickPathTemplate,directory,(double) getpid());
else
(void) FormatLocaleString(path,MagickPathExtent,
- "%s%smagick-%.20gXXXXXXXXXXXX",directory,DirectorySeparator,(double)
- getpid());
+ "%s%smagick-%.20g" MagickPathTemplate,directory,DirectorySeparator,
+ (double) getpid());
directory=DestroyString(directory);
#if defined(MAGICKCORE_WINDOWS_SUPPORT)
{
*/
(void) GetPathTemplate(path);
key=GetRandomKey(random_info,6);
- p=path+strlen(path)-12;
+ p=path+strlen(path)-strlen(MagickPathTemplate);
datum=GetStringInfoDatum(key);
for (i=0; i < (ssize_t) GetStringInfoLength(key); i++)
{
break;
}
#endif
- key=GetRandomKey(random_info,12);
- p=path+strlen(path)-12;
+ key=GetRandomKey(random_info,strlen(MagickPathTemplate));
+ p=path+strlen(path)-strlen(MagickPathTemplate);
datum=GetStringInfoDatum(key);
for (i=0; i < (ssize_t) GetStringInfoLength(key); i++)
{
time_limit[MagickFormatExtent],
width_limit[MagickFormatExtent];
+ magick_unreferenced(exception);
+
if (file == (const FILE *) NULL)
file=stdout;
if (resource_semaphore == (SemaphoreInfo *) NULL)
MagickFormatExtent,width_limit);
(void) FormatMagickSize(resource_info.height_limit,MagickFalse,"P",
MagickFormatExtent,height_limit);
- (void) FormatMagickSize(resource_info.area_limit,MagickFalse,"B",
+ (void) FormatMagickSize(resource_info.area_limit,MagickFalse,"P",
MagickFormatExtent,area_limit);
(void) FormatMagickSize(resource_info.memory_limit,MagickTrue,"B",
MagickFormatExtent,memory_limit);
}
case HeightResource:
{
- resource_info.width=(MagickOffsetType) size;
- (void) FormatMagickSize((MagickSizeType) resource_info.width,MagickFalse,
+ resource_info.height=(MagickOffsetType) size;
+ (void) FormatMagickSize((MagickSizeType) resource_info.height,MagickFalse,
"P",MagickFormatExtent,resource_current);
- (void) FormatMagickSize(resource_info.width_limit,MagickFalse,"P",
+ (void) FormatMagickSize(resource_info.height_limit,MagickFalse,"P",
MagickFormatExtent,resource_limit);
break;
}
ActivateSemaphoreInfo(&resource_semaphore);
LockSemaphoreInfo(resource_semaphore);
if (temporary_resources != (SplayTreeInfo *) NULL)
- status=DeleteNodeFromSplayTree(temporary_resources, (const void *) path);
+ status=DeleteNodeFromSplayTree(temporary_resources,(const void *) path);
UnlockSemaphoreInfo(resource_semaphore);
(void) CopyMagickString(cache_path,path,MagickPathExtent);
AppendImageFormat("cache",cache_path);
case WidthResource:
{
resource_info.width_limit=limit;
- value=GetPolicyValue("width");
+ value=GetPolicyValue("resource:width");
if (value != (char *) NULL)
resource_info.width_limit=MagickMin(limit,StringToSizeType(value,
100.0));
case HeightResource:
{
resource_info.height_limit=limit;
- value=GetPolicyValue("height");
+ value=GetPolicyValue("resource:height");
if (value != (char *) NULL)
resource_info.height_limit=MagickMin(limit,StringToSizeType(value,
100.0));
case AreaResource:
{
resource_info.area_limit=limit;
- value=GetPolicyValue("area");
+ value=GetPolicyValue("resource:area");
if (value != (char *) NULL)
resource_info.area_limit=MagickMin(limit,StringToSizeType(value,100.0));
break;
case MemoryResource:
{
resource_info.memory_limit=limit;
- value=GetPolicyValue("memory");
+ value=GetPolicyValue("resource:memory");
if (value != (char *) NULL)
resource_info.memory_limit=MagickMin(limit,StringToSizeType(value,
100.0));
case MapResource:
{
resource_info.map_limit=limit;
- value=GetPolicyValue("map");
+ value=GetPolicyValue("resource:map");
if (value != (char *) NULL)
resource_info.map_limit=MagickMin(limit,StringToSizeType(value,100.0));
break;
case DiskResource:
{
resource_info.disk_limit=limit;
- value=GetPolicyValue("disk");
+ value=GetPolicyValue("resource:disk");
if (value != (char *) NULL)
resource_info.disk_limit=MagickMin(limit,StringToSizeType(value,100.0));
break;
case FileResource:
{
resource_info.file_limit=limit;
- value=GetPolicyValue("file");
+ value=GetPolicyValue("resource:file");
if (value != (char *) NULL)
resource_info.file_limit=MagickMin(limit,StringToSizeType(value,100.0));
break;
case ThreadResource:
{
resource_info.thread_limit=limit;
- value=GetPolicyValue("thread");
+ value=GetPolicyValue("resource:thread");
if (value != (char *) NULL)
resource_info.thread_limit=MagickMin(limit,StringToSizeType(value,
100.0));
if (resource_info.thread_limit > GetOpenMPMaximumThreads())
resource_info.thread_limit=GetOpenMPMaximumThreads();
- else if (resource_info.thread_limit == 0)
- resource_info.thread_limit=1;
+ else
+ if (resource_info.thread_limit == 0)
+ resource_info.thread_limit=1;
break;
}
case ThrottleResource:
{
resource_info.throttle_limit=limit;
- value=GetPolicyValue("throttle");
+ value=GetPolicyValue("resource:throttle");
if (value != (char *) NULL)
- resource_info.throttle_limit=MagickMin(limit,StringToSizeType(value,
+ resource_info.throttle_limit=MagickMax(limit,StringToSizeType(value,
100.0));
- if (resource_info.throttle_limit > GetOpenMPMaximumThreads())
- resource_info.throttle_limit=GetOpenMPMaximumThreads();
break;
}
case TimeResource:
{
resource_info.time_limit=limit;
- value=GetPolicyValue("time");
+ value=GetPolicyValue("resource:time");
if (value != (char *) NULL)
resource_info.time_limit=MagickMin(limit,StringToSizeType(value,100.0));
+ ResetPixelCacheEpoch();
break;
}
default: