From cd2cd1803dda951bcfff101c44032ae17e52655f Mon Sep 17 00:00:00 2001 From: cristy <urban-warrior@git.imagemagick.org> Date: Tue, 18 Mar 2014 12:10:55 +0000 Subject: [PATCH] --- MagickCore/coder.c | 10 ++--- MagickCore/color.c | 35 +++++++--------- MagickCore/configure.c | 35 +++++++--------- MagickCore/delegate.c | 38 ++++++++--------- MagickCore/locale.c | 92 +++++++++++++++++++++--------------------- MagickCore/log.c | 32 ++++++--------- MagickCore/magic.c | 30 ++++++-------- MagickCore/magick.c | 2 + MagickCore/mime.c | 35 +++++++--------- MagickCore/policy.c | 30 ++++++-------- coders/jp2.c | 5 --- coders/jpeg.c | 3 -- coders/tiff.c | 5 --- 13 files changed, 148 insertions(+), 204 deletions(-) diff --git a/MagickCore/coder.c b/MagickCore/coder.c index b5d29d88d..abf84acf6 100644 --- a/MagickCore/coder.c +++ b/MagickCore/coder.c @@ -320,8 +320,8 @@ static SplayTreeInfo *AcquireCoderCache(const char *filename, option=(const StringInfo *) GetNextValueInLinkedList(options); while (option != (const StringInfo *) NULL) { - status&=LoadCoderCache(coder_cache,(const char *) GetStringInfoDatum(option), - GetStringInfoPath(option),0,exception); + status&=LoadCoderCache(coder_cache,(const char *) + GetStringInfoDatum(option),GetStringInfoPath(option),0,exception); option=(const StringInfo *) GetNextValueInLinkedList(options); } options=DestroyConfigureOptions(options); @@ -641,8 +641,8 @@ MagickExport char **GetCoderList(const char *pattern, % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% IsCoderTreeInstantiated() determines if the coder tree is instantiated. -% If not, it instantiates the tree and returns it. +% IsCoderTreeInstantiated() determines if the coder tree is instantiated. If +% not, it instantiates the tree and returns it. % % The format of the IsCoderInstantiated method is: % @@ -661,7 +661,7 @@ static MagickBooleanType IsCoderTreeInstantiated(ExceptionInfo *exception) ActivateSemaphoreInfo(&coder_semaphore); LockSemaphoreInfo(coder_semaphore); if (coder_cache == (SplayTreeInfo *) NULL) - (void) AcquireCoderCache(MagickCoderFilename,exception); + coder_cache=AcquireCoderCache(MagickCoderFilename,exception); UnlockSemaphoreInfo(coder_semaphore); } return(coder_cache != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse); diff --git a/MagickCore/color.c b/MagickCore/color.c index 672e56863..3c21b09b1 100644 --- a/MagickCore/color.c +++ b/MagickCore/color.c @@ -796,7 +796,8 @@ static SemaphoreInfo */ static MagickBooleanType IsColorCacheInstantiated(ExceptionInfo *), - LoadColorCache(const char *,const char *,const size_t,ExceptionInfo *); + LoadColorCache(LinkedListInfo *,const char *,const char *,const size_t, + ExceptionInfo *); /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -851,8 +852,8 @@ static LinkedListInfo *AcquireColorCache(const char *filename, option=(const StringInfo *) GetNextValueInLinkedList(options); while (option != (const StringInfo *) NULL) { - status&=LoadColorCache((const char *) GetStringInfoDatum(option), - GetStringInfoPath(option),0,exception); + status&=LoadColorCache(color_cache,(const char *) + GetStringInfoDatum(option),GetStringInfoPath(option),0,exception); option=(const StringInfo *) GetNextValueInLinkedList(options); } options=DestroyConfigureOptions(options); @@ -1006,9 +1007,8 @@ MagickExport const ColorInfo *GetColorCompliance(const char *name, *q; assert(exception != (ExceptionInfo *) NULL); - if (color_cache == (LinkedListInfo *) NULL) - if (IfMagickFalse(IsColorCacheInstantiated(exception))) - return((const ColorInfo *) NULL); + if (IfMagickFalse(IsColorCacheInstantiated(exception))) + return((const ColorInfo *) NULL); /* Strip names of whitespace. */ @@ -1905,8 +1905,9 @@ MagickExport MagickBooleanType ListColorInfo(FILE *file, % % The format of the LoadColorCache method is: % -% MagickBooleanType LoadColorCache(const char *xml,const char *filename, -% const size_t depth,ExceptionInfo *exception) +% MagickBooleanType LoadColorCache(LinkedListInfo *color_cache, +% const char *xml,const char *filename,const size_t depth, +% ExceptionInfo *exception) % % A description of each parameter follows: % @@ -1919,8 +1920,9 @@ MagickExport MagickBooleanType ListColorInfo(FILE *file, % o exception: return any errors or warnings in this structure. % */ -static MagickBooleanType LoadColorCache(const char *xml,const char *filename, - const size_t depth,ExceptionInfo *exception) +static MagickBooleanType LoadColorCache(LinkedListInfo *color_cache, + const char *xml,const char *filename,const size_t depth, + ExceptionInfo *exception) { char keyword[MaxTextExtent], @@ -1942,16 +1944,6 @@ static MagickBooleanType LoadColorCache(const char *xml,const char *filename, "Loading color file \"%s\" ...",filename); if (xml == (char *) NULL) return(MagickFalse); - if (color_cache == (LinkedListInfo *) NULL) - { - color_cache=NewLinkedList(0); - if (color_cache == (LinkedListInfo *) NULL) - { - ThrowFileException(exception,ResourceLimitError, - "MemoryAllocationFailed",filename); - return(MagickFalse); - } - } status=MagickTrue; color_info=(ColorInfo *) NULL; token=AcquireString(xml); @@ -2016,7 +2008,8 @@ static MagickBooleanType LoadColorCache(const char *xml,const char *filename, xml=FileToXML(path,~0UL); if (xml != (char *) NULL) { - status=LoadColorCache(xml,path,depth+1,exception); + status&=LoadColorCache(color_cache,xml,path,depth+1, + exception); xml=(char *) RelinquishMagickMemory(xml); } } diff --git a/MagickCore/configure.c b/MagickCore/configure.c index 0ce41603e..9f1915132 100644 --- a/MagickCore/configure.c +++ b/MagickCore/configure.c @@ -118,7 +118,8 @@ static SemaphoreInfo */ static MagickBooleanType IsConfigureCacheInstantiated(ExceptionInfo *), - LoadConfigureCache(const char *,const char *,const size_t,ExceptionInfo *); + LoadConfigureCache(LinkedListInfo *,const char *,const char *,const size_t, + ExceptionInfo *); /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -131,7 +132,7 @@ static MagickBooleanType % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% AcquireConfigureCache() caches one or more configure configuration files which +% AcquireConfigureCache() caches one or more configure configurations which % provides a mapping between configure attributes and a configure name. % % The format of the AcquireConfigureCache method is: @@ -173,8 +174,8 @@ static LinkedListInfo *AcquireConfigureCache(const char *filename, option=(const StringInfo *) GetNextValueInLinkedList(options); while (option != (const StringInfo *) NULL) { - status&=LoadConfigureCache((const char *) GetStringInfoDatum(option), - GetStringInfoPath(option),0,exception); + status&=LoadConfigureCache(configure_cache,(const char *) + GetStringInfoDatum(option),GetStringInfoPath(option),0,exception); option=(const StringInfo *) GetNextValueInLinkedList(options); } options=DestroyConfigureOptions(options); @@ -1082,8 +1083,8 @@ MagickExport MagickBooleanType ListConfigureInfo(FILE *file, (void) FormatLocaleFile(file,"\n"); } (void) fflush(file); - configure_info=(const ConfigureInfo **) - RelinquishMagickMemory((void *) configure_info); + configure_info=(const ConfigureInfo **) RelinquishMagickMemory((void *) + configure_info); return(MagickTrue); } @@ -1103,8 +1104,8 @@ MagickExport MagickBooleanType ListConfigureInfo(FILE *file, % % The format of the LoadConfigureCache method is: % -% MagickBooleanType LoadConfigureCache(const char *xml,const char *filename, -% const size_t depth,ExceptionInfo *exception) +% MagickBooleanType LoadConfigureCache(LinkedListInfo *configure_cache, +% const char *xml,const char *filename,const size_t depth,ExceptionInfo *exception) % % A description of each parameter follows: % @@ -1117,8 +1118,9 @@ MagickExport MagickBooleanType ListConfigureInfo(FILE *file, % o exception: return any errors or warnings in this structure. % */ -static MagickBooleanType LoadConfigureCache(const char *xml,const char *filename, - const size_t depth,ExceptionInfo *exception) +static MagickBooleanType LoadConfigureCache(LinkedListInfo *configure_cache, + const char *xml,const char *filename,const size_t depth, + ExceptionInfo *exception) { char keyword[MaxTextExtent], @@ -1138,16 +1140,6 @@ static MagickBooleanType LoadConfigureCache(const char *xml,const char *filename */ (void) LogMagickEvent(ConfigureEvent,GetMagickModule(), "Loading configure file \"%s\" ...",filename); - if (configure_cache == (LinkedListInfo *) NULL) - { - configure_cache=NewLinkedList(0); - if (configure_cache == (LinkedListInfo *) NULL) - { - ThrowFileException(exception,ResourceLimitError, - "MemoryAllocationFailed",filename); - return(MagickFalse); - } - } status=MagickTrue; configure_info=(ConfigureInfo *) NULL; token=AcquireString((char *) xml); @@ -1212,7 +1204,8 @@ static MagickBooleanType LoadConfigureCache(const char *xml,const char *filename xml=FileToXML(path,~0UL); if (xml != (char *) NULL) { - status=LoadConfigureCache(xml,path,depth+1,exception); + status&=LoadConfigureCache(configure_cache,xml,path, + depth+1,exception); xml=(char *) RelinquishMagickMemory(xml); } } diff --git a/MagickCore/delegate.c b/MagickCore/delegate.c index 160a842de..0df9dd579 100644 --- a/MagickCore/delegate.c +++ b/MagickCore/delegate.c @@ -140,7 +140,8 @@ static SemaphoreInfo */ static MagickBooleanType IsDelegateCacheInstantiated(ExceptionInfo *), - LoadDelegateCache(const char *,const char *,const size_t,ExceptionInfo *); + LoadDelegateCache(LinkedListInfo *,const char *,const char *,const size_t, + ExceptionInfo *); /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -193,15 +194,16 @@ static LinkedListInfo *AcquireDelegateCache(const char *filename, option=(const StringInfo *) GetNextValueInLinkedList(options); while (option != (const StringInfo *) NULL) { - status&=LoadDelegateCache((const char *) GetStringInfoDatum(option), - GetStringInfoPath(option),0,exception); + status&=LoadDelegateCache(delegate_cache,(const char *) + GetStringInfoDatum(option),GetStringInfoPath(option),0,exception); option=(const StringInfo *) GetNextValueInLinkedList(options); } options=DestroyConfigureOptions(options); } #endif if (IfMagickTrue(IsLinkedListEmpty(delegate_cache))) - status&=LoadDelegateCache(DelegateMap,"built-in",0,exception); + status&=LoadDelegateCache(delegate_cache,DelegateMap,"built-in",0, + exception); return(delegate_cache); } @@ -432,9 +434,8 @@ MagickExport const DelegateInfo *GetDelegateInfo(const char *decode, *p; assert(exception != (ExceptionInfo *) NULL); - if (delegate_cache == (LinkedListInfo *) NULL) - if( IfMagickFalse(IsDelegateCacheInstantiated(exception)) ) - return((const DelegateInfo *) NULL); + if (IfMagickFalse(IsDelegateCacheInstantiated(exception))) + return((const DelegateInfo *) NULL); /* Search for named delegate. */ @@ -1258,8 +1259,9 @@ MagickExport MagickBooleanType ListDelegateInfo(FILE *file, % % The format of the LoadDelegateCache method is: % -% MagickBooleanType LoadDelegateCache(const char *xml,const char *filename, -% const size_t depth,ExceptionInfo *exception) +% MagickBooleanType LoadDelegateCache(LinkedListInfo *delegate_cache, +% const char *xml,const char *filename,const size_t depth, +% ExceptionInfo *exception) % % A description of each parameter follows: % @@ -1272,8 +1274,9 @@ MagickExport MagickBooleanType ListDelegateInfo(FILE *file, % o exception: return any errors or warnings in this structure. % */ -static MagickBooleanType LoadDelegateCache(const char *xml,const char *filename, - const size_t depth,ExceptionInfo *exception) +static MagickBooleanType LoadDelegateCache(LinkedListInfo *delegate_cache, + const char *xml,const char *filename,const size_t depth, + ExceptionInfo *exception) { char keyword[MaxTextExtent], @@ -1295,16 +1298,6 @@ static MagickBooleanType LoadDelegateCache(const char *xml,const char *filename, "Loading delegate configuration file \"%s\" ...",filename); if (xml == (const char *) NULL) return(MagickFalse); - if (delegate_cache == (LinkedListInfo *) NULL) - { - delegate_cache=NewLinkedList(0); - if (delegate_cache == (LinkedListInfo *) NULL) - { - ThrowFileException(exception,ResourceLimitError, - "MemoryAllocationFailed",filename); - return(MagickFalse); - } - } status=MagickTrue; delegate_info=(DelegateInfo *) NULL; token=AcquireString(xml); @@ -1369,7 +1362,8 @@ static MagickBooleanType LoadDelegateCache(const char *xml,const char *filename, xml=FileToXML(path,~0UL); if (xml != (char *) NULL) { - status=LoadDelegateCache(xml,path,depth+1,exception); + status&=LoadDelegateCache(delegate_cache,xml,path, + depth+1,exception); xml=(char *) RelinquishMagickMemory(xml); } } diff --git a/MagickCore/locale.c b/MagickCore/locale.c index 65557fdc5..02626ea6f 100644 --- a/MagickCore/locale.c +++ b/MagickCore/locale.c @@ -106,8 +106,8 @@ static volatile locale_t */ static MagickBooleanType IsLocaleTreeInstantiated(ExceptionInfo *), - LoadLocaleCache(const char *,const char *,const char *,const size_t, - ExceptionInfo *); + LoadLocaleCache(SplayTreeInfo *,const char *,const char *,const char *, + const size_t,ExceptionInfo *); #if defined(MAGICKCORE_HAVE_STRTOD_L) /* @@ -212,8 +212,9 @@ static SplayTreeInfo *AcquireLocaleSplayTree(const char *filename, option=(const StringInfo *) GetNextValueInLinkedList(options); while (option != (const StringInfo *) NULL) { - status&=LoadLocaleCache((const char *) GetStringInfoDatum(option), - GetStringInfoPath(option),locale,0,exception); + status&=LoadLocaleCache(locale_cache,(const char *) + GetStringInfoDatum(option),GetStringInfoPath(option),locale,0, + exception); option=(const StringInfo *) GetNextValueInLinkedList(options); } options=DestroyLocaleOptions(options); @@ -223,8 +224,9 @@ static SplayTreeInfo *AcquireLocaleSplayTree(const char *filename, option=(const StringInfo *) GetNextValueInLinkedList(options); while (option != (const StringInfo *) NULL) { - status&=LoadLocaleCache((const char *) GetStringInfoDatum(option), - GetStringInfoPath(option),locale,0,exception); + status&=LoadLocaleCache(locale_cache,(const char *) + GetStringInfoDatum(option),GetStringInfoPath(option),locale,0, + exception); option=(const StringInfo *) GetNextValueInLinkedList(options); } options=DestroyLocaleOptions(options); @@ -232,7 +234,8 @@ static SplayTreeInfo *AcquireLocaleSplayTree(const char *filename, } #endif if (GetNumberOfNodesInSplayTree(locale_cache) == 0) - status&=LoadLocaleCache(LocaleMap,"built-in",locale,0,exception); + status&=LoadLocaleCache(locale_cache,LocaleMap,"built-in",locale,0, + exception); return(locale_cache); } @@ -910,35 +913,38 @@ MagickExport const char *GetLocaleValue(const LocaleInfo *locale_info) */ static MagickBooleanType IsLocaleTreeInstantiated(ExceptionInfo *exception) { - if (locale_semaphore == (SemaphoreInfo *) NULL) - ActivateSemaphoreInfo(&locale_semaphore); - LockSemaphoreInfo(locale_semaphore); if (locale_cache == (SplayTreeInfo *) NULL) { - char - *locale; - - register const char - *p; - - locale=(char *) NULL; - p=setlocale(LC_CTYPE,(const char *) NULL); - if (p != (const char *) NULL) - locale=ConstantString(p); - if (locale == (char *) NULL) - locale=GetEnvironmentValue("LC_ALL"); - if (locale == (char *) NULL) - locale=GetEnvironmentValue("LC_MESSAGES"); - if (locale == (char *) NULL) - locale=GetEnvironmentValue("LC_CTYPE"); - if (locale == (char *) NULL) - locale=GetEnvironmentValue("LANG"); - if (locale == (char *) NULL) - locale=ConstantString("C"); - locale_cache=AcquireLocaleSplayTree(LocaleFilename,locale,exception); - locale=DestroyString(locale); + if (locale_semaphore == (SemaphoreInfo *) NULL) + ActivateSemaphoreInfo(&locale_semaphore); + LockSemaphoreInfo(locale_semaphore); + if (locale_cache == (SplayTreeInfo *) NULL) + { + char + *locale; + + register const char + *p; + + locale=(char *) NULL; + p=setlocale(LC_CTYPE,(const char *) NULL); + if (p != (const char *) NULL) + locale=ConstantString(p); + if (locale == (char *) NULL) + locale=GetEnvironmentValue("LC_ALL"); + if (locale == (char *) NULL) + locale=GetEnvironmentValue("LC_MESSAGES"); + if (locale == (char *) NULL) + locale=GetEnvironmentValue("LC_CTYPE"); + if (locale == (char *) NULL) + locale=GetEnvironmentValue("LANG"); + if (locale == (char *) NULL) + locale=ConstantString("C"); + locale_cache=AcquireLocaleSplayTree(LocaleFilename,locale,exception); + locale=DestroyString(locale); + } + UnlockSemaphoreInfo(locale_semaphore); } - UnlockSemaphoreInfo(locale_semaphore); return(locale_cache != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse); } @@ -1090,8 +1096,9 @@ MagickExport MagickBooleanType ListLocaleInfo(FILE *file, % % The format of the LoadLocaleCache method is: % -% MagickBooleanType LoadLocaleCache(const char *xml,const char *filename, -% const size_t depth,ExceptionInfo *exception) +% MagickBooleanType LoadLocaleCache(SplayTreeInfo *locale_cache, +% const char *xml,const char *filename,const size_t depth, +% ExceptionInfo *exception) % % A description of each parameter follows: % @@ -1149,8 +1156,9 @@ static inline size_t MagickMin(const size_t x,const size_t y) return(y); } -static MagickBooleanType LoadLocaleCache(const char *xml,const char *filename, - const char *locale,const size_t depth,ExceptionInfo *exception) +static MagickBooleanType LoadLocaleCache(SplayTreeInfo *locale_cache, + const char *xml,const char *filename,const char *locale,const size_t depth, + ExceptionInfo *exception) { char keyword[MaxTextExtent], @@ -1180,13 +1188,6 @@ static MagickBooleanType LoadLocaleCache(const char *xml,const char *filename, "Loading locale configure file \"%s\" ...",filename); if (xml == (const char *) NULL) return(MagickFalse); - if (locale_cache == (SplayTreeInfo *) NULL) - { - locale_cache=NewSplayTree(CompareSplayTreeString,(void *(*)(void *)) NULL, - DestroyLocaleNode); - if (locale_cache == (SplayTreeInfo *) NULL) - return(MagickFalse); - } status=MagickTrue; locale_info=(LocaleInfo *) NULL; *tag='\0'; @@ -1270,7 +1271,8 @@ static MagickBooleanType LoadLocaleCache(const char *xml,const char *filename, xml=FileToXML(path,~0UL); if (xml != (char *) NULL) { - status=LoadLocaleCache(xml,path,locale,depth+1,exception); + status&=LoadLocaleCache(locale_cache,xml,path,locale, + depth+1,exception); xml=(char *) RelinquishMagickMemory(xml); } } diff --git a/MagickCore/log.c b/MagickCore/log.c index 457ff115d..9a7739f60 100644 --- a/MagickCore/log.c +++ b/MagickCore/log.c @@ -199,7 +199,8 @@ static LogInfo static MagickBooleanType IsLogCacheInstantiated(ExceptionInfo *), - LoadLogCache(const char *,const char *,const size_t,ExceptionInfo *); + LoadLogCache(LinkedListInfo *,const char *,const char *,const size_t, + ExceptionInfo *); /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -254,7 +255,7 @@ static LinkedListInfo *AcquireLogCache(const char *filename, option=(const StringInfo *) GetNextValueInLinkedList(options); while (option != (const StringInfo *) NULL) { - status&=LoadLogCache((const char *) GetStringInfoDatum(option), + status&=LoadLogCache(log_cache,(const char *) GetStringInfoDatum(option), GetStringInfoPath(option),0,exception); option=(const StringInfo *) GetNextValueInLinkedList(options); } @@ -613,8 +614,8 @@ MagickExport const char *GetLogName(void) % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% IsLogCacheInstantiated() determines if the log list is instantiated. If not, -% it instantiates the list and returns it. +% IsLogCacheInstantiated() determines if the log list is instantiated. If +% not, it instantiates the list and returns it. % % The format of the IsLogInstantiated method is: % @@ -1325,7 +1326,7 @@ MagickBooleanType LogMagickEventList(const LogEventType type,const char *module, "encoding=\"UTF-8\" standalone=\"yes\"?>\n"); (void) FormatLocaleFile(log_info->file,"<log>\n"); } - (void) FormatLocaleFile(log_info->file," <event>%s</event>\n",text); + (void) FormatLocaleFile(log_info->file," <event>%s</event>\n",text); (void) fflush(log_info->file); } if ((log_info->handler_mask & MethodHandler) != 0) @@ -1380,8 +1381,8 @@ MagickBooleanType LogMagickEvent(const LogEventType type,const char *module, % % The format of the LoadLogCache method is: % -% MagickBooleanType LoadLogCache(const char *xml,const char *filename, -% const size_t depth,ExceptionInfo *exception) +% MagickBooleanType LoadLogCache(LinkedListInfo *log_cache,const char *xml, +% const char *filename,const size_t depth,ExceptionInfo *exception) % % A description of each parameter follows: % @@ -1394,8 +1395,8 @@ MagickBooleanType LogMagickEvent(const LogEventType type,const char *module, % o exception: return any errors or warnings in this structure. % */ -static MagickBooleanType LoadLogCache(const char *xml,const char *filename, - const size_t depth,ExceptionInfo *exception) +static MagickBooleanType LoadLogCache(LinkedListInfo *log_cache,const char *xml, + const char *filename,const size_t depth,ExceptionInfo *exception) { char keyword[MaxTextExtent], @@ -1415,16 +1416,6 @@ static MagickBooleanType LoadLogCache(const char *xml,const char *filename, */ if (xml == (const char *) NULL) return(MagickFalse); - if (log_cache == (LinkedListInfo *) NULL) - { - log_cache=NewLinkedList(0); - if (log_cache == (LinkedListInfo *) NULL) - { - ThrowFileException(exception,ResourceLimitError, - "MemoryAllocationFailed",filename); - return(MagickFalse); - } - } status=MagickTrue; token=AcquireString((const char *) xml); for (q=(const char *) xml; *q != '\0'; ) @@ -1488,7 +1479,8 @@ static MagickBooleanType LoadLogCache(const char *xml,const char *filename, xml=FileToXML(path,~0UL); if (xml != (char *) NULL) { - status&=LoadLogCache(xml,path,depth+1,exception); + status&=LoadLogCache(log_cache,xml,path,depth+1, + exception); xml=DestroyString(xml); } } diff --git a/MagickCore/magic.c b/MagickCore/magic.c index 39402b376..44db99092 100644 --- a/MagickCore/magic.c +++ b/MagickCore/magic.c @@ -215,7 +215,8 @@ static SemaphoreInfo */ static MagickBooleanType IsMagicCacheInstantiated(ExceptionInfo *), - LoadMagicCache(const char *,const char *,const size_t,ExceptionInfo *); + LoadMagicCache(LinkedListInfo *,const char *,const char *,const size_t, + ExceptionInfo *); /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -275,8 +276,8 @@ static LinkedListInfo *AcquireMagicCache(const char *filename, while (option != (const StringInfo *) NULL) { (void) CopyMagickString(path,GetStringInfoPath(option),MaxTextExtent); - status&=LoadMagicCache((const char *) GetStringInfoDatum(option), - GetStringInfoPath(option),0,exception); + status&=LoadMagicCache(magic_cache,(const char *) + GetStringInfoDatum(option),GetStringInfoPath(option),0,exception); option=(const StringInfo *) GetNextValueInLinkedList(options); } options=DestroyConfigureOptions(options); @@ -738,8 +739,9 @@ MagickExport MagickBooleanType ListMagicInfo(FILE *file, % % The format of the LoadMagicCache method is: % -% MagickBooleanType LoadMagicCache(const char *xml,const char *filename, -% const size_t depth,ExceptionInfo *exception) +% MagickBooleanType LoadMagicCache(LinkedListInfo *magic_cache, +% const char *xml,const char *filename,const size_t depth, +% ExceptionInfo *exception) % % A description of each parameter follows: % @@ -752,8 +754,9 @@ MagickExport MagickBooleanType ListMagicInfo(FILE *file, % o exception: return any errors or warnings in this structure. % */ -static MagickBooleanType LoadMagicCache(const char *xml,const char *filename, - const size_t depth,ExceptionInfo *exception) +static MagickBooleanType LoadMagicCache(LinkedListInfo *magic_cache, + const char *xml,const char *filename,const size_t depth, + ExceptionInfo *exception) { char keyword[MaxTextExtent], @@ -775,16 +778,6 @@ static MagickBooleanType LoadMagicCache(const char *xml,const char *filename, "Loading magic configure file \"%s\" ...",filename); if (xml == (char *) NULL) return(MagickFalse); - if (magic_cache == (LinkedListInfo *) NULL) - { - magic_cache=NewLinkedList(0); - if (magic_cache == (LinkedListInfo *) NULL) - { - ThrowFileException(exception,ResourceLimitError, - "MemoryAllocationFailed",filename); - return(MagickFalse); - } - } status=MagickTrue; magic_info=(MagicInfo *) NULL; token=AcquireString(xml); @@ -849,7 +842,8 @@ static MagickBooleanType LoadMagicCache(const char *xml,const char *filename, xml=FileToXML(path,~0UL); if (xml != (char *) NULL) { - status=LoadMagicCache(xml,path,depth+1,exception); + status&=LoadMagicCache(magic_cache,xml,path,depth+1, + exception); xml=(char *) RelinquishMagickMemory(xml); } } diff --git a/MagickCore/magick.c b/MagickCore/magick.c index d06d9daaa..b5d6c58d0 100644 --- a/MagickCore/magick.c +++ b/MagickCore/magick.c @@ -1444,6 +1444,8 @@ MagickExport MagickInfo *RegisterMagickInfo(MagickInfo *magick_info) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",magick_info->name); if (magick_list == (SplayTreeInfo *) NULL) return((MagickInfo *) NULL); + if (magick_info->thread_support == NoThreadSupport) + magick_info->semaphore=AcquireSemaphoreInfo(); status=AddValueToSplayTree(magick_list,magick_info->name,magick_info); if (status == MagickFalse) ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); diff --git a/MagickCore/mime.c b/MagickCore/mime.c index 981ede4c6..ca0f6425c 100644 --- a/MagickCore/mime.c +++ b/MagickCore/mime.c @@ -125,7 +125,8 @@ static SemaphoreInfo */ static MagickBooleanType IsMimeCacheInstantiated(ExceptionInfo *), - LoadMimeCache(const char *,const char *,const size_t,ExceptionInfo *); + LoadMimeCache(LinkedListInfo *,const char *,const char *,const size_t, + ExceptionInfo *); /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -138,8 +139,8 @@ static MagickBooleanType % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% AcquireMimeCache() caches one or more magic configurations which provides a -% mapping between magic attributes and a magic name. +% AcquireMimeCache() caches one or more magic configurations which provides +% a mapping between magic attributes and a magic name. % % The format of the AcquireMimeCache method is: % @@ -178,15 +179,15 @@ MagickExport LinkedListInfo *AcquireMimeCache(const char *filename, option=(const StringInfo *) GetNextValueInLinkedList(options); while (option != (const StringInfo *) NULL) { - status&=LoadMimeCache((const char *) GetStringInfoDatum(option), - GetStringInfoPath(option),0,exception); + status&=LoadMimeCache(mime_cache,(const char *) + GetStringInfoDatum(option),GetStringInfoPath(option),0,exception); option=(const StringInfo *) GetNextValueInLinkedList(options); } options=DestroyConfigureOptions(options); } #endif if (IsLinkedListEmpty(mime_cache) != MagickFalse) - status&=LoadMimeCache(MimeMap,"built-in",0,exception); + status&=LoadMimeCache(mime_cache,MimeMap,"built-in",0,exception); return(mime_cache); } @@ -774,8 +775,9 @@ MagickExport MagickBooleanType ListMimeInfo(FILE *file,ExceptionInfo *exception) % % The format of the LoadMimeCache method is: % -% MagickBooleanType LoadMimeCache(const char *xml,const char *filename, -% const size_t depth,ExceptionInfo *exception) +% MagickBooleanType LoadMimeCache(LinkedListInfo *mime_cache, +% const char *xml,const char *filename,const size_t depth, +% ExceptionInfo *exception) % % A description of each parameter follows: % @@ -788,8 +790,9 @@ MagickExport MagickBooleanType ListMimeInfo(FILE *file,ExceptionInfo *exception) % o exception: return any errors or warnings in this structure. % */ -static MagickBooleanType LoadMimeCache(const char *xml,const char *filename, - const size_t depth,ExceptionInfo *exception) +static MagickBooleanType LoadMimeCache(LinkedListInfo *mime_cache, + const char *xml,const char *filename,const size_t depth, + ExceptionInfo *exception) { const char *attribute; @@ -812,16 +815,6 @@ static MagickBooleanType LoadMimeCache(const char *xml,const char *filename, "Loading mime map \"%s\" ...",filename); if (xml == (const char *) NULL) return(MagickFalse); - if (mime_cache == (LinkedListInfo *) NULL) - { - mime_cache=NewLinkedList(0); - if (mime_cache == (LinkedListInfo *) NULL) - { - ThrowFileException(exception,ResourceLimitError, - "MemoryAllocationFailed",filename); - return(MagickFalse); - } - } mime_map=NewXMLTree(xml,exception); if (mime_map == (XMLTreeInfo *) NULL) return(MagickFalse); @@ -855,7 +848,7 @@ static MagickBooleanType LoadMimeCache(const char *xml,const char *filename, xml=FileToXML(path,~0UL); if (xml != (char *) NULL) { - status=LoadMimeCache(xml,path,depth+1,exception); + status&=LoadMimeCache(mime_cache,xml,path,depth+1,exception); xml=DestroyString(xml); } } diff --git a/MagickCore/policy.c b/MagickCore/policy.c index 6db232082..4dfd099fc 100644 --- a/MagickCore/policy.c +++ b/MagickCore/policy.c @@ -131,7 +131,8 @@ static SemaphoreInfo */ static MagickBooleanType IsPolicyCacheInstantiated(ExceptionInfo *), - LoadPolicyCache(const char *,const char *,const size_t,ExceptionInfo *); + LoadPolicyCache(LinkedListInfo *,const char *,const char *,const size_t, + ExceptionInfo *); /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -186,8 +187,8 @@ static LinkedListInfo *AcquirePolicyCache(const char *filename, option=(const StringInfo *) GetNextValueInLinkedList(options); while (option != (const StringInfo *) NULL) { - status&=LoadPolicyCache((const char *) GetStringInfoDatum(option), - GetStringInfoPath(option),0,exception); + status&=LoadPolicyCache(policy_cache,(const char *) + GetStringInfoDatum(option),GetStringInfoPath(option),0,exception); option=(const StringInfo *) GetNextValueInLinkedList(options); } options=DestroyConfigureOptions(options); @@ -715,8 +716,9 @@ MagickExport MagickBooleanType ListPolicyInfo(FILE *file, % % The format of the LoadPolicyCache method is: % -% MagickBooleanType LoadPolicyCache(const char *xml,const char *filename, -% const size_t depth,ExceptionInfo *exception) +% MagickBooleanType LoadPolicyCache(LinkedListInfo *policy_cache, +% const char *xml,const char *filename,const size_t depth, +% ExceptionInfo *exception) % % A description of each parameter follows: % @@ -729,8 +731,9 @@ MagickExport MagickBooleanType ListPolicyInfo(FILE *file, % o exception: return any errors or warnings in this structure. % */ -static MagickBooleanType LoadPolicyCache(const char *xml,const char *filename, - const size_t depth,ExceptionInfo *exception) +static MagickBooleanType LoadPolicyCache(LinkedListInfo *policy_cache, + const char *xml,const char *filename,const size_t depth, + ExceptionInfo *exception) { char keyword[MaxTextExtent], @@ -752,16 +755,6 @@ static MagickBooleanType LoadPolicyCache(const char *xml,const char *filename, "Loading policy file \"%s\" ...",filename); if (xml == (char *) NULL) return(MagickFalse); - if (policy_cache == (LinkedListInfo *) NULL) - { - policy_cache=NewLinkedList(0); - if (policy_cache == (LinkedListInfo *) NULL) - { - ThrowFileException(exception,ResourceLimitError, - "MemoryAllocationFailed",filename); - return(MagickFalse); - } - } status=MagickTrue; policy_info=(PolicyInfo *) NULL; token=AcquireString(xml); @@ -826,7 +819,8 @@ static MagickBooleanType LoadPolicyCache(const char *xml,const char *filename, xml=FileToXML(path,~0UL); if (xml != (char *) NULL) { - status=LoadPolicyCache(xml,path,depth+1,exception); + status&=LoadPolicyCache(policy_cache,xml,path,depth+1, + exception); xml=(char *) RelinquishMagickMemory(xml); } } diff --git a/coders/jp2.c b/coders/jp2.c index 4fbdf60b3..effdd9e2a 100644 --- a/coders/jp2.c +++ b/coders/jp2.c @@ -536,7 +536,6 @@ ModuleExport size_t RegisterJP2Image(void) entry->adjoin=MagickFalse; entry->seekable_stream=MagickTrue; entry->thread_support=NoThreadSupport; - entry->semaphore=AcquireSemaphoreInfo(); #if defined(MAGICKCORE_LIBOPENJP2_DELEGATE) entry->decoder=(DecodeImageHandler *) ReadJP2Image; entry->encoder=(EncodeImageHandler *) WriteJP2Image; @@ -552,7 +551,6 @@ ModuleExport size_t RegisterJP2Image(void) entry->adjoin=MagickFalse; entry->seekable_stream=MagickTrue; entry->thread_support=NoThreadSupport; - entry->semaphore=AcquireSemaphoreInfo(); #if defined(MAGICKCORE_LIBOPENJP2_DELEGATE) entry->decoder=(DecodeImageHandler *) ReadJP2Image; entry->encoder=(EncodeImageHandler *) WriteJP2Image; @@ -568,7 +566,6 @@ ModuleExport size_t RegisterJP2Image(void) entry->adjoin=MagickFalse; entry->seekable_stream=MagickTrue; entry->thread_support=NoThreadSupport; - entry->semaphore=AcquireSemaphoreInfo(); #if defined(MAGICKCORE_LIBOPENJP2_DELEGATE) entry->decoder=(DecodeImageHandler *) ReadJP2Image; entry->encoder=(EncodeImageHandler *) WriteJP2Image; @@ -584,7 +581,6 @@ ModuleExport size_t RegisterJP2Image(void) entry->adjoin=MagickFalse; entry->seekable_stream=MagickTrue; entry->thread_support=NoThreadSupport; - entry->semaphore=AcquireSemaphoreInfo(); #if defined(MAGICKCORE_LIBOPENJP2_DELEGATE) entry->decoder=(DecodeImageHandler *) ReadJP2Image; entry->encoder=(EncodeImageHandler *) WriteJP2Image; @@ -600,7 +596,6 @@ ModuleExport size_t RegisterJP2Image(void) entry->adjoin=MagickFalse; entry->seekable_stream=MagickTrue; entry->thread_support=NoThreadSupport; - entry->semaphore=AcquireSemaphoreInfo(); #if defined(MAGICKCORE_LIBOPENJP2_DELEGATE) entry->decoder=(DecodeImageHandler *) ReadJP2Image; entry->encoder=(EncodeImageHandler *) WriteJP2Image; diff --git a/coders/jpeg.c b/coders/jpeg.c index 4387d6e41..bbf3a8381 100644 --- a/coders/jpeg.c +++ b/coders/jpeg.c @@ -1506,7 +1506,6 @@ ModuleExport size_t RegisterJPEGImage(void) #endif entry=SetMagickInfo("JPEG"); entry->thread_support=NoThreadSupport; - entry->semaphore=AcquireSemaphoreInfo(); #if defined(MAGICKCORE_JPEG_DELEGATE) entry->decoder=(DecodeImageHandler *) ReadJPEGImage; entry->encoder=(EncodeImageHandler *) WriteJPEGImage; @@ -1521,7 +1520,6 @@ ModuleExport size_t RegisterJPEGImage(void) (void) RegisterMagickInfo(entry); entry=SetMagickInfo("JPG"); entry->thread_support=NoThreadSupport; - entry->semaphore=AcquireSemaphoreInfo(); #if defined(MAGICKCORE_JPEG_DELEGATE) entry->decoder=(DecodeImageHandler *) ReadJPEGImage; entry->encoder=(EncodeImageHandler *) WriteJPEGImage; @@ -1535,7 +1533,6 @@ ModuleExport size_t RegisterJPEGImage(void) (void) RegisterMagickInfo(entry); entry=SetMagickInfo("PJPEG"); entry->thread_support=NoThreadSupport; - entry->semaphore=AcquireSemaphoreInfo(); #if defined(MAGICKCORE_JPEG_DELEGATE) entry->decoder=(DecodeImageHandler *) ReadJPEGImage; entry->encoder=(EncodeImageHandler *) WriteJPEGImage; diff --git a/coders/tiff.c b/coders/tiff.c index 4270ea07c..d2e4f563c 100644 --- a/coders/tiff.c +++ b/coders/tiff.c @@ -1983,7 +1983,6 @@ ModuleExport size_t RegisterTIFFImage(void) entry->format_type=ImplicitFormatType; entry->seekable_stream=MagickTrue; entry->thread_support=NoThreadSupport; - entry->semaphore=AcquireSemaphoreInfo(); entry->description=ConstantString("Raw CCITT Group4"); entry->mime_type=ConstantString("image/tiff"); entry->module=ConstantString("TIFF"); @@ -1996,7 +1995,6 @@ ModuleExport size_t RegisterTIFFImage(void) entry->endian_support=MagickTrue; entry->seekable_stream=MagickTrue; entry->thread_support=NoThreadSupport; - entry->semaphore=AcquireSemaphoreInfo(); entry->description=ConstantString("Pyramid encoded TIFF"); entry->mime_type=ConstantString("image/tiff"); entry->module=ConstantString("TIFF"); @@ -2010,7 +2008,6 @@ ModuleExport size_t RegisterTIFFImage(void) entry->seekable_stream=MagickTrue; entry->stealth=MagickTrue; entry->thread_support=NoThreadSupport; - entry->semaphore=AcquireSemaphoreInfo(); entry->description=ConstantString(TIFFDescription); if (*version != '\0') entry->version=ConstantString(version); @@ -2026,7 +2023,6 @@ ModuleExport size_t RegisterTIFFImage(void) entry->endian_support=MagickTrue; entry->seekable_stream=MagickTrue; entry->thread_support=NoThreadSupport; - entry->semaphore=AcquireSemaphoreInfo(); entry->description=ConstantString(TIFFDescription); if (*version != '\0') entry->version=ConstantString(version); @@ -2042,7 +2038,6 @@ ModuleExport size_t RegisterTIFFImage(void) entry->endian_support=MagickTrue; entry->seekable_stream=MagickTrue; entry->thread_support=NoThreadSupport; - entry->semaphore=AcquireSemaphoreInfo(); entry->description=ConstantString("Tagged Image File Format (64-bit)"); if (*version != '\0') entry->version=ConstantString(version); -- 2.40.0