ma=(MagicInfo *) a;
mb=(MagicInfo *) b;
- return((int) ((mb->offset+mb->length)-(ma->offset+ma->length)));
+
+ if (ma->offset != mb->offset)
+ return((int) (ma->offset-mb->offset));
+
+ return((int) (mb->length-ma->length));
}
static LinkedListInfo *AcquireMagicCache(const char *filename,
magic_info->magic=(unsigned char *) p->magic;
magic_info->length=p->length;
magic_info->exempt=MagickTrue;
- magic_info->signature=MagickSignature;
+ magic_info->signature=MagickCoreSignature;
status&=InsertValueInSortedLinkedList(magic_cache,CompareMagickInfoSize,
NULL,magic_info);
if (status == MagickFalse)
register const MagicInfo
*p;
+ size_t
+ magickSize,
+ max;
+
static size_t
- size = 0;
+ size=0;
assert(exception != (ExceptionInfo *) NULL);
if ((size != 0) || (IsMagicCacheInstantiated(exception) == MagickFalse))
return(size);
- /*
- The list is sorted so we can use the size of the first value.
- */
LockSemaphoreInfo(magic_semaphore);
ResetLinkedListIterator(magic_cache);
+ max=0;
p=(const MagicInfo *) GetNextValueInLinkedList(magic_cache);
- if (p != (const MagicInfo *) NULL)
- size=(size_t) (p->offset+p->length);
+ while (p != (const MagicInfo *) NULL)
+ {
+ magickSize=(size_t) (p->offset+p->length);
+ if (magickSize > max)
+ max=magickSize;
+ p=(const MagicInfo *) GetNextValueInLinkedList(magic_cache);
+ }
+ size=max;
UnlockSemaphoreInfo(magic_semaphore);
return(size);
}
{
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(magic_info != (MagicInfo *) NULL);
- assert(magic_info->signature == MagickSignature);
+ assert(magic_info->signature == MagickCoreSignature);
return(magic_info->name);
}
\f
(void) ResetMagickMemory(magic_info,0,sizeof(*magic_info));
magic_info->path=ConstantString(filename);
magic_info->exempt=MagickFalse;
- magic_info->signature=MagickSignature;
+ magic_info->signature=MagickCoreSignature;
continue;
}
if (magic_info == (MagicInfo *) NULL)