static MagickBooleanType
GetMagickModulePath(const char *,MagickModuleType,char *,ExceptionInfo *),
- InitializeModuleList(ExceptionInfo *),
+ IsModuleTreeInstantiated(ExceptionInfo *),
UnregisterModule(const ModuleInfo *,ExceptionInfo *);
static void
*/
MagickExport ModuleInfo *GetModuleInfo(const char *tag,ExceptionInfo *exception)
{
- if (module_list == (SplayTreeInfo *) NULL)
- if (InitializeModuleList(exception) == MagickFalse)
- return((ModuleInfo *) NULL);
+ 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_semaphore == (SemaphoreInfo *) NULL)
- ActivateSemaphoreInfo(&module_semaphore);
- LockSemaphoreInfo(module_semaphore);
if (module_list == (SplayTreeInfo *) NULL)
{
- MagickBooleanType
- status;
-
- ModuleInfo
- *module_info;
-
- module_list=NewSplayTree(CompareSplayTreeString,
- (void *(*)(void *)) NULL,DestroyModuleNode);
+ if (module_semaphore == (SemaphoreInfo *) NULL)
+ ActivateSemaphoreInfo(&module_semaphore);
+ LockSemaphoreInfo(module_semaphore);
if (module_list == (SplayTreeInfo *) NULL)
- ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
- module_info=AcquireModuleInfo((const char *) NULL,"[boot-strap]");
- module_info->stealth=MagickTrue;
- status=AddValueToSplayTree(module_list,module_info->tag,module_info);
- if (status == MagickFalse)
- ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
- if (lt_dlinit() != 0)
- ThrowFatalException(ModuleFatalError,"UnableToInitializeModuleLoader");
+ {
+ MagickBooleanType
+ status;
+
+ ModuleInfo
+ *module_info;
+
+ module_list=NewSplayTree(CompareSplayTreeString,
+ (void *(*)(void *)) NULL,DestroyModuleNode);
+ if (module_list == (SplayTreeInfo *) NULL)
+ ThrowFatalException(ResourceLimitFatalError,
+ "MemoryAllocationFailed");
+ module_info=AcquireModuleInfo((const char *) NULL,"[boot-strap]");
+ module_info->stealth=MagickTrue;
+ status=AddValueToSplayTree(module_list,module_info->tag,module_info);
+ if (status == MagickFalse)
+ ThrowFatalException(ResourceLimitFatalError,
+ "MemoryAllocationFailed");
+ if (lt_dlinit() != 0)
+ ThrowFatalException(ModuleFatalError,
+ "UnableToInitializeModuleLoader");
+ }
+ UnlockSemaphoreInfo(module_semaphore);
}
- UnlockSemaphoreInfo(module_semaphore);
return(module_list != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
}
\f
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);
}