% MagickCore Self-adjusting Binary Search Tree 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 %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% AddValueToSplayTree() adds the given key and value to the splay-tree.
-% Both key and value are used as is, without coping or cloning.
+% AddValueToSplayTree() adds the given key and value to the splay-tree. Both
+% key and value are used as is, without coping or cloning. It returns
+% MagickTrue on success, otherwise MagickFalse.
%
% The format of the AddValueToSplayTree method is:
%
%
*/
-static NodeInfo *LinkSplayTreeNodes(NodeInfo **nodes,const size_t low,
+static inline NodeInfo *LinkSplayTreeNodes(NodeInfo **nodes,const size_t low,
const size_t high)
{
register NodeInfo
return(node);
}
-static int SplayTreeToNodeArray(NodeInfo *node,const void *nodes)
+static inline int SplayTreeToNodeArray(NodeInfo *node,const void *nodes)
{
register const NodeInfo
***p;
if (nodes == (NodeInfo **) NULL)
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
node=nodes;
- (void) IterateOverSplayTree(splay_tree,SplayTreeToNodeArray,
- (const void *) &node);
+ (void) IterateOverSplayTree(splay_tree,SplayTreeToNodeArray,(const void *)
+ &node);
splay_tree->root=LinkSplayTreeNodes(nodes,0,splay_tree->nodes-1);
splay_tree->balance=MagickFalse;
nodes=(NodeInfo **) RelinquishMagickMemory(nodes);
%
*/
-static void *GetFirstSplayTreeNode(SplayTreeInfo *splay_tree)
+static inline void *GetFirstSplayTreeNode(SplayTreeInfo *splay_tree)
{
register NodeInfo
*node;
}
splay_tree->signature=(~MagickSignature);
UnlockSemaphoreInfo(splay_tree->semaphore);
- DestroySemaphoreInfo(&splay_tree->semaphore);
+ RelinquishSemaphoreInfo(&splay_tree->semaphore);
splay_tree=(SplayTreeInfo *) RelinquishMagickMemory(splay_tree);
return(splay_tree);
}
splay_tree->next=(void *) NULL;
splay_tree->nodes=0;
splay_tree->debug=IsEventLogging();
- splay_tree->semaphore=AllocateSemaphoreInfo();
+ splay_tree->semaphore=AcquireSemaphoreInfo();
splay_tree->signature=MagickSignature;
return(splay_tree);
}
%
*/
-static NodeInfo *Splay(SplayTreeInfo *splay_tree,const size_t depth,
+static inline NodeInfo *Splay(SplayTreeInfo *splay_tree,const size_t depth,
const void *key,NodeInfo **node,NodeInfo **parent,NodeInfo **grandparent)
{
int
(void) Splay(splay_tree,0UL,key,&splay_tree->root,(NodeInfo **) NULL,
(NodeInfo **) NULL);
if (splay_tree->balance != MagickFalse)
- ThrowFatalException(ResourceLimitFatalError,
- "MemoryAllocationFailed");
+ ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
}
splay_tree->key=(void *) key;
}