]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/module.c
The 8bim profile will be updated when the iptc profile is changed.
[imagemagick] / MagickCore / module.c
index 8d5c61f5e61412199e075ee85b9d64b48138a6f0..94acdd43aae34674712bedf4100569de8803d350 100644 (file)
@@ -93,9 +93,6 @@ static SemaphoreInfo
 
 static SplayTreeInfo
   *module_list = (SplayTreeInfo *) NULL;
-
-static volatile MagickBooleanType
-  instantiate_module = MagickFalse;
 \f
 /*
   Forward declarations.
@@ -105,7 +102,7 @@ static const ModuleInfo
 
 static MagickBooleanType
   GetMagickModulePath(const char *,MagickModuleType,char *,ExceptionInfo *),
-  InitializeModuleList(ExceptionInfo *),
+  IsModuleTreeInstantiated(ExceptionInfo *),
   UnregisterModule(const ModuleInfo *,ExceptionInfo *);
 
 static void
@@ -184,13 +181,6 @@ MagickExport void DestroyModuleList(void)
 #if defined(MAGICKCORE_MODULES_SUPPORT)
   if (module_list != (SplayTreeInfo *) NULL)
     module_list=DestroySplayTree(module_list);
-  if (instantiate_module != MagickFalse)
-    {
-#if !defined(MAGICKCORE_JP2_DELEGATE)
-      (void) lt_dlexit();  /* Jasper has an errant atexit() handler */
-#endif
-      instantiate_module=MagickFalse;
-    }
 #endif
   UnlockSemaphoreInfo(module_semaphore);
 }
@@ -225,29 +215,26 @@ MagickExport void DestroyModuleList(void)
 */
 MagickExport ModuleInfo *GetModuleInfo(const char *tag,ExceptionInfo *exception)
 {
-  if ((module_list == (SplayTreeInfo *) NULL) ||
-      (instantiate_module == MagickFalse))
-    if (InitializeModuleList(exception) == MagickFalse)
-      return((ModuleInfo *) NULL);
-  if ((module_list == (SplayTreeInfo *) NULL) ||
-      (GetNumberOfNodesInSplayTree(module_list) == 0))
+  ModuleInfo
+    *module_info;
+
+  if (IsModuleTreeInstantiated(exception) == MagickFalse)
     return((ModuleInfo *) NULL);
+  LockSemaphoreInfo(module_semaphore);
+  ResetSplayTreeIterator(module_list);
   if ((tag == (const char *) NULL) || (LocaleCompare(tag,"*") == 0))
     {
-      ModuleInfo
-        *p;
-
 #if defined(MAGICKCORE_MODULES_SUPPORT)
       if (LocaleCompare(tag,"*") == 0)
         (void) OpenModules(exception);
 #endif
-      LockSemaphoreInfo(module_semaphore);
-      ResetSplayTreeIterator(module_list);
-      p=(ModuleInfo *) GetNextValueInSplayTree(module_list);
+      module_info=(ModuleInfo *) GetNextValueInSplayTree(module_list);
       UnlockSemaphoreInfo(module_semaphore);
-      return(p);
+      return(module_info);
     }
-  return((ModuleInfo *) GetValueFromSplayTree(module_list,tag));
+  module_info=(ModuleInfo *) GetValueFromSplayTree(module_list,tag);
+  UnlockSemaphoreInfo(module_semaphore);
+  return(module_info);
 }
 \f
 /*
@@ -824,17 +811,18 @@ static MagickBooleanType GetMagickModulePath(const char *filename,
 %                                                                             %
 %                                                                             %
 %                                                                             %
-%   I n i t i a l i z e M o d u l e L i s t                                   %
+%   I s M o d u l e T r e e I n s t a n t i a t e d                           %
 %                                                                             %
 %                                                                             %
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  InitializeModuleList() initializes the module loader.
+%  IsModuleTreeInstantiated() determines if the module tree is instantiated.
+%  If not, it instantiates the tree and returns it.
 %
-%  The format of the InitializeModuleList() method is:
+%  The format of the IsModuleTreeInstantiated() method is:
 %
-%      InitializeModuleList(Exceptioninfo *exception)
+%      IsModuleTreeInstantiated(Exceptioninfo *exception)
 %
 %  A description of each parameter follows.
 %
@@ -862,17 +850,15 @@ static void *DestroyModuleNode(void *module_info)
   return(RelinquishMagickMemory(p));
 }
 
-static MagickBooleanType InitializeModuleList(
+static MagickBooleanType IsModuleTreeInstantiated(
   ExceptionInfo *magick_unused(exception))
 {
-  if ((module_list == (SplayTreeInfo *) NULL) &&
-      (instantiate_module == MagickFalse))
+  if (module_list == (SplayTreeInfo *) NULL)
     {
       if (module_semaphore == (SemaphoreInfo *) NULL)
         ActivateSemaphoreInfo(&module_semaphore);
       LockSemaphoreInfo(module_semaphore);
-      if ((module_list == (SplayTreeInfo *) NULL) &&
-          (instantiate_module == MagickFalse))
+      if (module_list == (SplayTreeInfo *) NULL)
         {
           MagickBooleanType
             status;
@@ -894,7 +880,6 @@ static MagickBooleanType InitializeModuleList(
           if (lt_dlinit() != 0)
             ThrowFatalException(ModuleFatalError,
               "UnableToInitializeModuleLoader");
-          instantiate_module=MagickTrue;
         }
       UnlockSemaphoreInfo(module_semaphore);
     }
@@ -1164,9 +1149,10 @@ MagickPrivate MagickBooleanType ModuleComponentGenesis(void)
   MagickBooleanType
     status;
 
-  module_semaphore=AcquireSemaphoreInfo();
+  if (module_semaphore == (SemaphoreInfo *) NULL)
+    module_semaphore=AcquireSemaphoreInfo();
   exception=AcquireExceptionInfo();
-  status=InitializeModuleList(exception);
+  status=IsModuleTreeInstantiated(exception);
   exception=DestroyExceptionInfo(exception);
   return(status);
 }
@@ -1612,6 +1598,12 @@ static MagickBooleanType UnregisterModule(const ModuleInfo *module_info,
   return(MagickTrue);
 }
 #else
+
+#if !defined(MAGICKCORE_BUILD_MODULES)
+extern size_t
+  analyzeImage(Image **,const int,const char **,ExceptionInfo *);
+#endif
+
 MagickExport MagickBooleanType ListModuleInfo(FILE *magick_unused(file),
   ExceptionInfo *magick_unused(exception))
 {
@@ -1643,9 +1635,6 @@ MagickExport MagickBooleanType InvokeDynamicImageFilter(const char *tag,
   (void) exception;
 #else
   {
-    extern size_t
-      analyzeImage(Image **,const int,const char **,ExceptionInfo *);
-
     ImageFilterHandler
       *image_filter;