static SplayTreeInfo
*module_list = (SplayTreeInfo *) NULL;
-
-static volatile MagickBooleanType
- instantiate_module = MagickFalse;
\f
/*
Forward declarations.
static MagickBooleanType
GetMagickModulePath(const char *,MagickModuleType,char *,ExceptionInfo *),
- InitializeModuleList(ExceptionInfo *),
+ IsModuleTreeInstantiated(ExceptionInfo *),
UnregisterModule(const ModuleInfo *,ExceptionInfo *);
static 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);
}
*/
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
/*
% %
% %
% %
-% 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.
%
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;
if (lt_dlinit() != 0)
ThrowFatalException(ModuleFatalError,
"UnableToInitializeModuleLoader");
- instantiate_module=MagickTrue;
}
UnlockSemaphoreInfo(module_semaphore);
}
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);
}
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))
{
(void) exception;
#else
{
- extern size_t
- analyzeImage(Image **,const int,const char **,ExceptionInfo *);
-
ImageFilterHandler
*image_filter;