% MagickCore Hash-map and Linked-list Methods %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% December 2002 %
% %
% %
-% Copyright 1999-2012 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 %
*tail,
*next;
- MagickBooleanType
- debug;
-
SemaphoreInfo
*semaphore;
LinkedListInfo
**map;
- MagickBooleanType
- debug;
-
SemaphoreInfo
*semaphore;
assert(list_info != (LinkedListInfo *) NULL);
assert(list_info->signature == MagickSignature);
- list_info->debug=IsEventLogging();
- if (list_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
if (list_info->elements == list_info->capacity)
return(MagickFalse);
next=(ElementInfo *) AcquireMagickMemory(sizeof(*next));
assert(list_info != (LinkedListInfo *) NULL);
assert(list_info->signature == MagickSignature);
- if (list_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
LockSemaphoreInfo(list_info->semaphore);
next=list_info->head;
while (next != (ElementInfo *) NULL)
p=(const char *) target;
q=(const char *) source;
- return(LocaleCompare(p,q) == 0 ? MagickTrue : MagickFalse);
+ return(IsMagickTrue(LocaleCompare(p,q)));
}
\f
/*
MagickExport MagickBooleanType CompareHashmapStringInfo(const void *target,
const void *source)
{
- const StringInfo
- *p,
- *q;
-
- p=(const StringInfo *) target;
- q=(const StringInfo *) source;
- return(CompareStringInfo(p,q) == 0 ? MagickTrue : MagickFalse);
+ return(IsMagickTrue(LocaleCompare((const char *)target,
+ (const char *)source)));
}
\f
/*
assert(hashmap_info != (HashmapInfo *) NULL);
assert(hashmap_info->signature == MagickSignature);
- if (hashmap_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
LockSemaphoreInfo(hashmap_info->semaphore);
for (i=0; i < (ssize_t) hashmap_info->capacity; i++)
{
hashmap_info->map);
hashmap_info->signature=(~MagickSignature);
UnlockSemaphoreInfo(hashmap_info->semaphore);
- DestroySemaphoreInfo(&hashmap_info->semaphore);
+ RelinquishSemaphoreInfo(&hashmap_info->semaphore);
hashmap_info=(HashmapInfo *) RelinquishMagickMemory(hashmap_info);
return(hashmap_info);
}
assert(list_info != (LinkedListInfo *) NULL);
assert(list_info->signature == MagickSignature);
- if (list_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
LockSemaphoreInfo(list_info->semaphore);
for (next=list_info->head; next != (ElementInfo *) NULL; )
{
}
list_info->signature=(~MagickSignature);
UnlockSemaphoreInfo(list_info->semaphore);
- DestroySemaphoreInfo(&list_info->semaphore);
+ RelinquishSemaphoreInfo(&list_info->semaphore);
list_info=(LinkedListInfo *) RelinquishMagickMemory(list_info);
return(list_info);
}
assert(list_info != (LinkedListInfo *) NULL);
assert(list_info->signature == MagickSignature);
- if (list_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
if (list_info->elements == 0)
return((void *) NULL);
LockSemaphoreInfo(list_info->semaphore);
assert(hashmap_info != (HashmapInfo *) NULL);
assert(hashmap_info->signature == MagickSignature);
- if (hashmap_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
LockSemaphoreInfo(hashmap_info->semaphore);
while (hashmap_info->next < hashmap_info->capacity)
{
list_info=hashmap_info->map[hashmap_info->next];
if (list_info != (LinkedListInfo *) NULL)
{
- if (hashmap_info->head_of_list == MagickFalse)
+ if (IfMagickFalse(hashmap_info->head_of_list))
{
list_info->next=list_info->head;
hashmap_info->head_of_list=MagickTrue;
assert(hashmap_info != (HashmapInfo *) NULL);
assert(hashmap_info->signature == MagickSignature);
- if (hashmap_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
LockSemaphoreInfo(hashmap_info->semaphore);
while (hashmap_info->next < hashmap_info->capacity)
{
list_info=hashmap_info->map[hashmap_info->next];
if (list_info != (LinkedListInfo *) NULL)
{
- if (hashmap_info->head_of_list == MagickFalse)
+ if (IfMagickFalse(hashmap_info->head_of_list))
{
list_info->next=list_info->head;
hashmap_info->head_of_list=MagickTrue;
assert(list_info != (LinkedListInfo *) NULL);
assert(list_info->signature == MagickSignature);
- if (list_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
LockSemaphoreInfo(list_info->semaphore);
if (list_info->next == (ElementInfo *) NULL)
{
{
assert(hashmap_info != (HashmapInfo *) NULL);
assert(hashmap_info->signature == MagickSignature);
- if (hashmap_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
return(hashmap_info->entries);
}
\f
{
assert(list_info != (LinkedListInfo *) NULL);
assert(list_info->signature == MagickSignature);
- if (list_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
return(list_info->elements);
}
\f
assert(hashmap_info != (HashmapInfo *) NULL);
assert(hashmap_info->signature == MagickSignature);
- if (hashmap_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
if (key == (const void *) NULL)
return((void *) NULL);
LockSemaphoreInfo(hashmap_info->semaphore);
if (hashmap_info->compare !=
(MagickBooleanType (*)(const void *,const void *)) NULL)
compare=hashmap_info->compare(key,entry->key);
- if (compare == MagickTrue)
+ if (IfMagickTrue(compare))
{
value=entry->value;
UnlockSemaphoreInfo(hashmap_info->semaphore);
assert(list_info != (LinkedListInfo *) NULL);
assert(list_info->signature == MagickSignature);
- if (list_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
if (index >= list_info->elements)
return((void *) NULL);
LockSemaphoreInfo(list_info->semaphore);
assert(list_info != (LinkedListInfo *) NULL);
assert(list_info->signature == MagickSignature);
- if (list_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
if (value == (const void *) NULL)
return(MagickFalse);
if ((index > list_info->elements) ||
assert(list_info != (LinkedListInfo *) NULL);
assert(list_info->signature == MagickSignature);
- if (list_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
if ((compare == (int (*)(const void *,const void *)) NULL) ||
(value == (const void *) NULL))
return(MagickFalse);
{
assert(hashmap_info != (HashmapInfo *) NULL);
assert(hashmap_info->signature == MagickSignature);
- if (hashmap_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
- return(hashmap_info->entries == 0 ? MagickTrue : MagickFalse);
+ return(IsMagickTrue(hashmap_info->entries == 0));
}
\f
/*
{
assert(list_info != (LinkedListInfo *) NULL);
assert(list_info->signature == MagickSignature);
- if (list_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
- return(list_info->elements == 0 ? MagickTrue : MagickFalse);
+ return(IsMagickTrue(list_info->elements == 0));
}
\f
/*
assert(list_info != (LinkedListInfo *) NULL);
assert(list_info->signature == MagickSignature);
- if (list_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
if (array == (void **) NULL)
return(MagickFalse);
LockSemaphoreInfo(list_info->semaphore);
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
(void) ResetMagickMemory(hashmap_info->map,0,(size_t) capacity*
sizeof(*hashmap_info->map));
- hashmap_info->debug=IsEventLogging();
- hashmap_info->semaphore=AllocateSemaphoreInfo();
+ hashmap_info->semaphore=AcquireSemaphoreInfo();
hashmap_info->signature=MagickSignature;
return(hashmap_info);
}
list_info->head=(ElementInfo *) NULL;
list_info->tail=(ElementInfo *) NULL;
list_info->next=(ElementInfo *) NULL;
- list_info->debug=MagickFalse;
- list_info->semaphore=AllocateSemaphoreInfo();
+ list_info->semaphore=AcquireSemaphoreInfo();
list_info->signature=MagickSignature;
return(list_info);
}
}
list_info->signature=(~MagickSignature);
UnlockSemaphoreInfo(list_info->semaphore);
- DestroySemaphoreInfo(&list_info->semaphore);
+ RelinquishSemaphoreInfo(&list_info->semaphore);
list_info=(LinkedListInfo *) RelinquishMagickMemory(list_info);
}
hashmap_info->map=(LinkedListInfo **) RelinquishMagickMemory(
assert(hashmap_info != (HashmapInfo *) NULL);
assert(hashmap_info->signature == MagickSignature);
- if (hashmap_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
if ((key == (void *) NULL) || (value == (void *) NULL))
return(MagickFalse);
next=(EntryInfo *) AcquireMagickMemory(sizeof(*next));
if (hashmap_info->compare !=
(MagickBooleanType (*)(const void *,const void *)) NULL)
compare=hashmap_info->compare(key,entry->key);
- if (compare == MagickTrue)
+ if( IfMagickTrue(compare) )
{
(void) RemoveElementFromLinkedList(list_info,i);
if (hashmap_info->relinquish_key != (void *(*)(void *)) NULL)
entry=(EntryInfo *) GetNextValueInLinkedList(list_info);
}
}
- if (InsertValueInLinkedList(list_info,0,next) == MagickFalse)
+ if (IfMagickFalse(InsertValueInLinkedList(list_info,0,next)))
{
next=(EntryInfo *) RelinquishMagickMemory(next);
UnlockSemaphoreInfo(hashmap_info->semaphore);
return(MagickFalse);
}
if (list_info->elements >= (hashmap_info->capacity-1))
- if (IncreaseHashmapCapacity(hashmap_info) == MagickFalse)
+ if (IfMagickFalse(IncreaseHashmapCapacity(hashmap_info)))
{
UnlockSemaphoreInfo(hashmap_info->semaphore);
return(MagickFalse);
assert(list_info != (LinkedListInfo *) NULL);
assert(list_info->signature == MagickSignature);
- if (list_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
if ((list_info->elements == 0) || (value == (const void *) NULL))
return((void *) NULL);
LockSemaphoreInfo(list_info->semaphore);
assert(list_info != (LinkedListInfo *) NULL);
assert(list_info->signature == MagickSignature);
- if (list_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
if (index >= list_info->elements)
return((void *) NULL);
LockSemaphoreInfo(list_info->semaphore);
assert(hashmap_info != (HashmapInfo *) NULL);
assert(hashmap_info->signature == MagickSignature);
- if (hashmap_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
if (key == (const void *) NULL)
return((void *) NULL);
LockSemaphoreInfo(hashmap_info->semaphore);
if (hashmap_info->compare !=
(MagickBooleanType (*)(const void *,const void *)) NULL)
compare=hashmap_info->compare(key,entry->key);
- if (compare == MagickTrue)
+ if( IfMagickTrue(compare) )
{
entry=(EntryInfo *) RemoveElementFromLinkedList(list_info,i);
if (entry == (EntryInfo *) NULL)
assert(list_info != (LinkedListInfo *) NULL);
assert(list_info->signature == MagickSignature);
- if (list_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
if (list_info->elements == 0)
return((void *) NULL);
LockSemaphoreInfo(list_info->semaphore);
{
assert(hashmap_info != (HashmapInfo *) NULL);
assert(hashmap_info->signature == MagickSignature);
- if (hashmap_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
LockSemaphoreInfo(hashmap_info->semaphore);
hashmap_info->next=0;
hashmap_info->head_of_list=MagickFalse;
{
assert(list_info != (LinkedListInfo *) NULL);
assert(list_info->signature == MagickSignature);
- if (list_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
LockSemaphoreInfo(list_info->semaphore);
list_info->next=list_info->head;
UnlockSemaphoreInfo(list_info->semaphore);