% Get/Set MagickCore Resources %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% September 2002 %
% %
% %
-% Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2014 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 %
#include "MagickCore/log.h"
#include "MagickCore/image.h"
#include "MagickCore/memory_.h"
+#include "MagickCore/nt-base-private.h"
#include "MagickCore/option.h"
#include "MagickCore/policy.h"
#include "MagickCore/random_.h"
static ResourceInfo
resource_info =
{
- MagickULLConstant(0),
- MagickULLConstant(0),
- MagickULLConstant(0),
- MagickULLConstant(0),
- MagickULLConstant(0),
- MagickULLConstant(0),
- MagickULLConstant(0),
- MagickULLConstant(0),
- MagickULLConstant(3072)*1024*1024,
- MagickULLConstant(1536)*1024*1024,
- MagickULLConstant(3072)*1024*1024,
- MagickResourceInfinity,
- MagickULLConstant(768),
- MagickULLConstant(1),
- MagickULLConstant(0),
- MagickResourceInfinity
+ MagickULLConstant(0), /* initial area */
+ MagickULLConstant(0), /* initial memory */
+ MagickULLConstant(0), /* initial map */
+ MagickULLConstant(0), /* initial disk */
+ MagickULLConstant(0), /* initial file */
+ MagickULLConstant(0), /* initial thread */
+ MagickULLConstant(0), /* initial throttle */
+ MagickULLConstant(0), /* initial time */
+ MagickULLConstant(3072)*1024*1024, /* area limit */
+ MagickULLConstant(1536)*1024*1024, /* memory limit */
+ MagickULLConstant(3072)*1024*1024, /* map limit */
+ MagickResourceInfinity, /* disk limit */
+ MagickULLConstant(768), /* file limit */
+ MagickULLConstant(1), /* thread limit */
+ MagickULLConstant(0), /* throttle limit */
+ MagickResourceInfinity /* time limit */
};
static SemaphoreInfo
status=MagickFalse;
(void) FormatMagickSize(size,MagickFalse,resource_request);
if (resource_semaphore == (SemaphoreInfo *) NULL)
- AcquireSemaphoreInfo(&resource_semaphore);
+ ActivateSemaphoreInfo(&resource_semaphore);
LockSemaphoreInfo(resource_semaphore);
switch (type)
{
path=(const char *) GetNextKeyInSplayTree(temporary_resources);
while (path != (const char *) NULL)
{
- (void) remove_utf8(path);
+ (void) ShredFile(path);
path=(const char *) GetNextKeyInSplayTree(temporary_resources);
}
}
static void *DestroyTemporaryResources(void *temporary_resource)
{
- (void) remove_utf8((char *) temporary_resource);
+ (void) ShredFile((char *) temporary_resource);
temporary_resource=DestroyString((char *) temporary_resource);
return((void *) NULL);
}
MagickBooleanType
status;
- register char
- *p;
-
struct stat
attributes;
(void) FormatLocaleString(path,MaxTextExtent,"%smagick-%.20gXXXXXXXXXXXX",
directory,(double) getpid());
else
- (void) FormatLocaleString(path,MaxTextExtent,"%s%smagick-%.20gXXXXXXXXXXXX",
- directory,DirectorySeparator,(double) getpid());
+ (void) FormatLocaleString(path,MaxTextExtent,
+ "%s%smagick-%.20gXXXXXXXXXXXX",directory,DirectorySeparator,
+ (double) getpid());
directory=DestroyString(directory);
- if (*DirectorySeparator != '/')
- for (p=path; *p != '\0'; p++)
+#if defined(MAGICKCORE_WINDOWS_SUPPORT)
+ {
+ register char
+ *p;
+
+ /*
+ Ghostscript does not like backslashes so we need to replace them. The
+ forward slash also works under Windows.
+ */
+ for (p=(path[1] == *DirectorySeparator ? path+2 : path); *p != '\0'; p++)
if (*p == *DirectorySeparator)
*p='/';
+ }
+#endif
return(MagickTrue);
}
*datum;
assert(path != (char *) NULL);
- (void) LogMagickEvent(ResourceEvent,GetMagickModule(),"%s",path);
+ (void) LogMagickEvent(ResourceEvent,GetMagickModule(),"...");
if (random_info == (RandomInfo *) NULL)
random_info=AcquireRandomInfo();
file=(-1);
if (file == -1)
return(file);
if (resource_semaphore == (SemaphoreInfo *) NULL)
- AcquireSemaphoreInfo(&resource_semaphore);
+ ActivateSemaphoreInfo(&resource_semaphore);
LockSemaphoreInfo(resource_semaphore);
if (temporary_resources == (SplayTreeInfo *) NULL)
temporary_resources=NewSplayTree(CompareSplayTreeString,
resource=0;
if (resource_semaphore == (SemaphoreInfo *) NULL)
- AcquireSemaphoreInfo(&resource_semaphore);
+ ActivateSemaphoreInfo(&resource_semaphore);
LockSemaphoreInfo(resource_semaphore);
switch (type)
{
if (file == (const FILE *) NULL)
file=stdout;
if (resource_semaphore == (SemaphoreInfo *) NULL)
- AcquireSemaphoreInfo(&resource_semaphore);
+ ActivateSemaphoreInfo(&resource_semaphore);
LockSemaphoreInfo(resource_semaphore);
(void) FormatMagickSize(resource_info.area_limit,MagickFalse,area_limit);
(void) FormatMagickSize(resource_info.memory_limit,MagickTrue,memory_limit);
(void) FormatMagickSize(size,MagickFalse,resource_request);
if (resource_semaphore == (SemaphoreInfo *) NULL)
- AcquireSemaphoreInfo(&resource_semaphore);
+ ActivateSemaphoreInfo(&resource_semaphore);
LockSemaphoreInfo(resource_semaphore);
switch (type)
{
}
(void) CopyMagickString(cache_path,path,MaxTextExtent);
AppendImageFormat("cache",cache_path);
- (void) remove_utf8(cache_path);
- return(remove_utf8(path) == 0 ? MagickTrue : MagickFalse);
+ (void) ShredFile(cache_path);
+ return(ShredFile(path));
}
\f
/*
/*
Set Magick resource limits.
*/
- AcquireSemaphoreInfo(&resource_semaphore);
+ if (resource_semaphore == (SemaphoreInfo *) NULL)
+ resource_semaphore=AcquireSemaphoreInfo();
pagesize=GetMagickPageSize();
pages=(-1);
#if defined(MAGICKCORE_HAVE_SYSCONF) && defined(_SC_PHYS_PAGES)
MagickPrivate void ResourceComponentTerminus(void)
{
if (resource_semaphore == (SemaphoreInfo *) NULL)
- AcquireSemaphoreInfo(&resource_semaphore);
+ resource_semaphore=AcquireSemaphoreInfo();
LockSemaphoreInfo(resource_semaphore);
if (temporary_resources != (SplayTreeInfo *) NULL)
temporary_resources=DestroySplayTree(temporary_resources);
if (random_info != (RandomInfo *) NULL)
random_info=DestroyRandomInfo(random_info);
UnlockSemaphoreInfo(resource_semaphore);
- DestroySemaphoreInfo(&resource_semaphore);
+ RelinquishSemaphoreInfo(&resource_semaphore);
}
\f
/*
*value;
if (resource_semaphore == (SemaphoreInfo *) NULL)
- AcquireSemaphoreInfo(&resource_semaphore);
+ resource_semaphore=AcquireSemaphoreInfo();
LockSemaphoreInfo(resource_semaphore);
value=(char *) NULL;
switch (type)