mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-03 02:31:03 -08:00
Incomplete response to code review. see <https://info.ravenbrook.com/mail/2014/03/07/11-21-03/0/>.
Copied from Perforce Change: 184735 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
2b9719e4bd
commit
2ce13f82dc
5 changed files with 96 additions and 115 deletions
172
mps/code/cbs.c
172
mps/code/cbs.c
|
|
@ -26,12 +26,11 @@ SRCID(cbs, "$Id$");
|
|||
#define CBSBlockSize(block) AddrOffset((block)->base, (block)->limit)
|
||||
|
||||
|
||||
#define cbsOfTree(_tree) TREE_ELT(CBS, tree, _tree)
|
||||
#define cbsBlockOfNode(_node) PARENT(CBSBlockStruct, node, _node)
|
||||
#define treeOfCBS(cbs) (&((cbs)->tree))
|
||||
#define nodeOfCBSBlock(block) (&((block)->node))
|
||||
#define keyOfCBSBlock(block) (&((block)->base))
|
||||
|
||||
#define cbsSplay(cbs) (&((cbs)->splayTreeStruct))
|
||||
#define cbsOfSplay(_splay) PARENT(CBSStruct, splayTreeStruct, _splay)
|
||||
#define cbsBlockTree(block) (&((block)->treeStruct))
|
||||
#define cbsBlockOfTree(_tree) TREE_ELT(CBSBlock, treeStruct, _tree)
|
||||
#define cbsBlockKey(block) (&((block)->base))
|
||||
#define cbsBlockPool(cbs) RVALUE((cbs)->blockPool)
|
||||
|
||||
|
||||
|
|
@ -67,13 +66,14 @@ Bool CBSCheck(CBS cbs)
|
|||
/* See .enter-leave.simple. */
|
||||
CHECKS(CBS, cbs);
|
||||
CHECKL(cbs != NULL);
|
||||
CHECKD(SplayTree, treeOfCBS(cbs));
|
||||
CHECKD(SplayTree, cbsSplay(cbs));
|
||||
/* nothing to check about treeSize */
|
||||
CHECKD(Pool, cbs->blockPool);
|
||||
CHECKU(Arena, cbs->arena);
|
||||
CHECKL(BoolCheck(cbs->fastFind));
|
||||
CHECKL(BoolCheck(cbs->inCBS));
|
||||
CHECKL(BoolCheck(cbs->ownPool));
|
||||
CHECKL(BoolCheck(cbs->zoned));
|
||||
/* No MeterCheck */
|
||||
|
||||
return TRUE;
|
||||
|
|
@ -85,7 +85,7 @@ static Bool CBSBlockCheck(CBSBlock block)
|
|||
/* See .enter-leave.simple. */
|
||||
UNUSED(block); /* Required because there is no signature */
|
||||
CHECKL(block != NULL);
|
||||
CHECKL(TreeCheck(nodeOfCBSBlock(block)));
|
||||
CHECKL(TreeCheck(cbsBlockTree(block)));
|
||||
|
||||
/* If the block is in the middle of being deleted, */
|
||||
/* the pointers will be equal. */
|
||||
|
|
@ -100,16 +100,16 @@ static Bool CBSBlockCheck(CBSBlock block)
|
|||
* See <design/splay/#type.splay.compare.method>
|
||||
*/
|
||||
|
||||
static Compare cbsCompare(Tree node, TreeKey key)
|
||||
static Compare cbsCompare(Tree tree, TreeKey key)
|
||||
{
|
||||
Addr base1, base2, limit2;
|
||||
CBSBlock cbsBlock;
|
||||
|
||||
AVER(node != NULL);
|
||||
AVER(node != TreeEMPTY);
|
||||
AVER(tree != NULL);
|
||||
AVER(tree != TreeEMPTY);
|
||||
|
||||
base1 = *(Addr *)key;
|
||||
cbsBlock = cbsBlockOfNode(node);
|
||||
cbsBlock = cbsBlockOfTree(tree);
|
||||
base2 = cbsBlock->base;
|
||||
limit2 = cbsBlock->limit;
|
||||
|
||||
|
|
@ -121,46 +121,46 @@ static Compare cbsCompare(Tree node, TreeKey key)
|
|||
return CompareEQUAL;
|
||||
}
|
||||
|
||||
static TreeKey cbsKey(Tree node)
|
||||
static TreeKey cbsKey(Tree tree)
|
||||
{
|
||||
return keyOfCBSBlock(cbsBlockOfNode(node));
|
||||
return cbsBlockKey(cbsBlockOfTree(tree));
|
||||
}
|
||||
|
||||
|
||||
/* cbsTestNode, cbsTestTree -- test for nodes larger than the S parameter */
|
||||
|
||||
static Bool cbsTestNode(SplayTree tree, Tree node,
|
||||
static Bool cbsTestNode(SplayTree splay, Tree tree,
|
||||
void *closureP, Size size)
|
||||
{
|
||||
CBSBlock block;
|
||||
|
||||
AVERT(SplayTree, tree);
|
||||
AVERT(Tree, node);
|
||||
AVERT(SplayTree, splay);
|
||||
AVERT(Tree, tree);
|
||||
AVER(closureP == NULL);
|
||||
AVER(size > 0);
|
||||
AVER(cbsOfTree(tree)->fastFind);
|
||||
AVER(cbsOfSplay(splay)->fastFind);
|
||||
|
||||
block = cbsBlockOfNode(node);
|
||||
block = cbsBlockOfTree(tree);
|
||||
|
||||
return CBSBlockSize(block) >= size;
|
||||
}
|
||||
|
||||
static Bool cbsTestTree(SplayTree tree, Tree node,
|
||||
static Bool cbsTestTree(SplayTree splay, Tree tree,
|
||||
void *closureP, Size size)
|
||||
{
|
||||
CBSBlock block;
|
||||
|
||||
AVERT(SplayTree, tree);
|
||||
AVERT(Tree, node);
|
||||
AVERT(SplayTree, splay);
|
||||
AVERT(Tree, tree);
|
||||
#if 0
|
||||
AVER(closureP == NULL);
|
||||
AVER(size > 0);
|
||||
#endif
|
||||
UNUSED(closureP);
|
||||
UNUSED(size);
|
||||
AVER(cbsOfTree(tree)->fastFind);
|
||||
AVER(cbsOfSplay(splay)->fastFind);
|
||||
|
||||
block = cbsBlockOfNode(node);
|
||||
block = cbsBlockOfTree(tree);
|
||||
|
||||
return block->maxSize >= size;
|
||||
}
|
||||
|
|
@ -168,26 +168,26 @@ static Bool cbsTestTree(SplayTree tree, Tree node,
|
|||
|
||||
/* cbsUpdateNode -- update size info after restructuring */
|
||||
|
||||
static void cbsUpdateNode(SplayTree tree, Tree node)
|
||||
static void cbsUpdateNode(SplayTree splay, Tree tree)
|
||||
{
|
||||
Size maxSize;
|
||||
CBSBlock block;
|
||||
|
||||
AVERT_CRITICAL(SplayTree, tree);
|
||||
AVERT_CRITICAL(Tree, node);
|
||||
AVER_CRITICAL(cbsOfTree(tree)->fastFind);
|
||||
AVERT_CRITICAL(SplayTree, splay);
|
||||
AVERT_CRITICAL(Tree, tree);
|
||||
AVER_CRITICAL(cbsOfSplay(splay)->fastFind);
|
||||
|
||||
block = cbsBlockOfNode(node);
|
||||
block = cbsBlockOfTree(tree);
|
||||
maxSize = CBSBlockSize(block);
|
||||
|
||||
if (TreeHasLeft(node)) {
|
||||
Size size = cbsBlockOfNode(TreeLeft(node))->maxSize;
|
||||
if (TreeHasLeft(tree)) {
|
||||
Size size = cbsBlockOfTree(TreeLeft(tree))->maxSize;
|
||||
if (size > maxSize)
|
||||
maxSize = size;
|
||||
}
|
||||
|
||||
if (TreeHasRight(node)) {
|
||||
Size size = cbsBlockOfNode(TreeRight(node))->maxSize;
|
||||
if (TreeHasRight(tree)) {
|
||||
Size size = cbsBlockOfTree(TreeRight(tree))->maxSize;
|
||||
if (size > maxSize)
|
||||
maxSize = size;
|
||||
}
|
||||
|
|
@ -198,28 +198,28 @@ static void cbsUpdateNode(SplayTree tree, Tree node)
|
|||
|
||||
/* cbsUpdateZonedNode -- update size and zone info after restructuring */
|
||||
|
||||
static void cbsUpdateZonedNode(SplayTree tree, Tree node)
|
||||
static void cbsUpdateZonedNode(SplayTree splay, Tree tree)
|
||||
{
|
||||
ZoneSet zones;
|
||||
CBSBlock block;
|
||||
Arena arena;
|
||||
|
||||
AVERT_CRITICAL(SplayTree, tree);
|
||||
AVERT_CRITICAL(Tree, node);
|
||||
AVER_CRITICAL(cbsOfTree(tree)->fastFind);
|
||||
AVER_CRITICAL(cbsOfTree(tree)->zoned);
|
||||
AVERT_CRITICAL(SplayTree, splay);
|
||||
AVERT_CRITICAL(Tree, tree);
|
||||
AVER_CRITICAL(cbsOfSplay(splay)->fastFind);
|
||||
AVER_CRITICAL(cbsOfSplay(splay)->zoned);
|
||||
|
||||
cbsUpdateNode(tree, node);
|
||||
cbsUpdateNode(splay, tree);
|
||||
|
||||
block = cbsBlockOfNode(node);
|
||||
arena = cbsOfTree(tree)->arena;
|
||||
block = cbsBlockOfTree(tree);
|
||||
arena = cbsOfSplay(splay)->arena;
|
||||
zones = ZoneSetOfRange(arena, CBSBlockBase(block), CBSBlockLimit(block));
|
||||
|
||||
if (TreeHasLeft(node))
|
||||
zones = ZoneSetUnion(zones, cbsBlockOfNode(TreeLeft(node))->zones);
|
||||
if (TreeHasLeft(tree))
|
||||
zones = ZoneSetUnion(zones, cbsBlockOfTree(TreeLeft(tree))->zones);
|
||||
|
||||
if (TreeHasRight(node))
|
||||
zones = ZoneSetUnion(zones, cbsBlockOfNode(TreeRight(node))->zones);
|
||||
if (TreeHasRight(tree))
|
||||
zones = ZoneSetUnion(zones, cbsBlockOfTree(TreeRight(tree))->zones);
|
||||
|
||||
block->zones = zones;
|
||||
}
|
||||
|
|
@ -264,7 +264,7 @@ Res CBSInit(CBS cbs, Arena arena, void *owner, Align alignment,
|
|||
update = cbsUpdateZonedNode;
|
||||
}
|
||||
|
||||
SplayTreeInit(treeOfCBS(cbs), cbsCompare, cbsKey, update);
|
||||
SplayTreeInit(cbsSplay(cbs), cbsCompare, cbsKey, update);
|
||||
|
||||
if (blockPool != NULL) {
|
||||
cbs->blockPool = blockPool;
|
||||
|
|
@ -313,7 +313,7 @@ void CBSFinish(CBS cbs)
|
|||
|
||||
cbs->sig = SigInvalid;
|
||||
|
||||
SplayTreeFinish(treeOfCBS(cbs));
|
||||
SplayTreeFinish(cbsSplay(cbs));
|
||||
if (cbs->ownPool)
|
||||
PoolDestroy(cbsBlockPool(cbs));
|
||||
}
|
||||
|
|
@ -334,7 +334,7 @@ static void cbsBlockDelete(CBS cbs, CBSBlock block)
|
|||
AVERT(CBSBlock, block);
|
||||
|
||||
METER_ACC(cbs->treeSearch, cbs->treeSize);
|
||||
b = SplayTreeDelete(treeOfCBS(cbs), nodeOfCBSBlock(block));
|
||||
b = SplayTreeDelete(cbsSplay(cbs), cbsBlockTree(block));
|
||||
AVER(b); /* expect block to be in the tree */
|
||||
STATISTIC(--cbs->treeSize);
|
||||
|
||||
|
|
@ -355,7 +355,7 @@ static void cbsBlockShrunk(CBS cbs, CBSBlock block, Size oldSize)
|
|||
AVER(oldSize > newSize);
|
||||
|
||||
if (cbs->fastFind) {
|
||||
SplayNodeRefresh(treeOfCBS(cbs), nodeOfCBSBlock(block));
|
||||
SplayNodeRefresh(cbsSplay(cbs), cbsBlockTree(block));
|
||||
AVER(CBSBlockSize(block) <= block->maxSize);
|
||||
}
|
||||
}
|
||||
|
|
@ -371,7 +371,7 @@ static void cbsBlockGrew(CBS cbs, CBSBlock block, Size oldSize)
|
|||
AVER(oldSize < newSize);
|
||||
|
||||
if (cbs->fastFind) {
|
||||
SplayNodeRefresh(treeOfCBS(cbs), nodeOfCBSBlock(block));
|
||||
SplayNodeRefresh(cbsSplay(cbs), cbsBlockTree(block));
|
||||
AVER(CBSBlockSize(block) <= block->maxSize);
|
||||
}
|
||||
}
|
||||
|
|
@ -395,7 +395,7 @@ static Res cbsBlockAlloc(CBSBlock *blockReturn, CBS cbs, Range range)
|
|||
goto failPoolAlloc;
|
||||
block = (CBSBlock)p;
|
||||
|
||||
TreeInit(nodeOfCBSBlock(block));
|
||||
TreeInit(cbsBlockTree(block));
|
||||
block->base = RangeBase(range);
|
||||
block->limit = RangeLimit(range);
|
||||
block->maxSize = CBSBlockSize(block);
|
||||
|
|
@ -419,7 +419,7 @@ static void cbsBlockInsert(CBS cbs, CBSBlock block)
|
|||
AVERT(CBSBlock, block);
|
||||
|
||||
METER_ACC(cbs->treeSearch, cbs->treeSize);
|
||||
b = SplayTreeInsert(treeOfCBS(cbs), nodeOfCBSBlock(block));
|
||||
b = SplayTreeInsert(cbsSplay(cbs), cbsBlockTree(block));
|
||||
AVER(b);
|
||||
STATISTIC(++cbs->treeSize);
|
||||
}
|
||||
|
|
@ -446,7 +446,7 @@ static Res cbsInsertIntoTree(Range rangeReturn, CBS cbs, Range range)
|
|||
limit = RangeLimit(range);
|
||||
|
||||
METER_ACC(cbs->treeSearch, cbs->treeSize);
|
||||
b = SplayTreeNeighbours(&leftSplay, &rightSplay, treeOfCBS(cbs), &base);
|
||||
b = SplayTreeNeighbours(&leftSplay, &rightSplay, cbsSplay(cbs), &base);
|
||||
if (!b) {
|
||||
res = ResFAIL;
|
||||
goto fail;
|
||||
|
|
@ -465,7 +465,7 @@ static Res cbsInsertIntoTree(Range rangeReturn, CBS cbs, Range range)
|
|||
leftCBS = NULL;
|
||||
leftMerge = FALSE;
|
||||
} else {
|
||||
leftCBS = cbsBlockOfNode(leftSplay);
|
||||
leftCBS = cbsBlockOfTree(leftSplay);
|
||||
AVER(leftCBS->limit <= base);
|
||||
leftMerge = leftCBS->limit == base;
|
||||
}
|
||||
|
|
@ -474,7 +474,7 @@ static Res cbsInsertIntoTree(Range rangeReturn, CBS cbs, Range range)
|
|||
rightCBS = NULL;
|
||||
rightMerge = FALSE;
|
||||
} else {
|
||||
rightCBS = cbsBlockOfNode(rightSplay);
|
||||
rightCBS = cbsBlockOfTree(rightSplay);
|
||||
if (rightCBS != NULL && limit > CBSBlockLimit(rightCBS)) {
|
||||
res = ResFAIL;
|
||||
goto fail;
|
||||
|
|
@ -554,7 +554,7 @@ static Res cbsDeleteFromTree(Range rangeReturn, CBS cbs, Range range)
|
|||
{
|
||||
Res res;
|
||||
CBSBlock cbsBlock;
|
||||
Tree node;
|
||||
Tree tree;
|
||||
Addr base, limit, oldBase, oldLimit;
|
||||
Size oldSize;
|
||||
|
||||
|
|
@ -567,11 +567,11 @@ static Res cbsDeleteFromTree(Range rangeReturn, CBS cbs, Range range)
|
|||
limit = RangeLimit(range);
|
||||
|
||||
METER_ACC(cbs->treeSearch, cbs->treeSize);
|
||||
if (!SplayTreeFind(&node, treeOfCBS(cbs), (void *)&base)) {
|
||||
if (!SplayTreeFind(&tree, cbsSplay(cbs), (void *)&base)) {
|
||||
res = ResFAIL;
|
||||
goto failSplayTreeSearch;
|
||||
}
|
||||
cbsBlock = cbsBlockOfNode(node);
|
||||
cbsBlock = cbsBlockOfTree(tree);
|
||||
|
||||
if (limit > cbsBlock->limit) {
|
||||
res = ResFAIL;
|
||||
|
|
@ -669,16 +669,16 @@ static Res cbsBlockDescribe(CBSBlock block, mps_lib_FILE *stream)
|
|||
return res;
|
||||
}
|
||||
|
||||
static Res cbsSplayNodeDescribe(Tree node, mps_lib_FILE *stream)
|
||||
static Res cbsSplayNodeDescribe(Tree tree, mps_lib_FILE *stream)
|
||||
{
|
||||
Res res;
|
||||
|
||||
if (node == TreeEMPTY)
|
||||
if (tree == TreeEMPTY)
|
||||
return ResFAIL;
|
||||
if (stream == NULL)
|
||||
return ResFAIL;
|
||||
|
||||
res = cbsBlockDescribe(cbsBlockOfNode(node), stream);
|
||||
res = cbsBlockDescribe(cbsBlockOfTree(tree), stream);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -714,7 +714,7 @@ static Bool cbsIterateVisit(Tree tree, void *closureP, Size closureS)
|
|||
|
||||
UNUSED(closureS);
|
||||
|
||||
cbsBlock = cbsBlockOfNode(tree);
|
||||
cbsBlock = cbsBlockOfTree(tree);
|
||||
RangeInit(&range, CBSBlockBase(cbsBlock), CBSBlockLimit(cbsBlock));
|
||||
if (!closure->iterate(cbs, &range, closure->closureP, closure->closureS))
|
||||
return FALSE;
|
||||
|
|
@ -725,14 +725,14 @@ static Bool cbsIterateVisit(Tree tree, void *closureP, Size closureS)
|
|||
void CBSIterate(CBS cbs, CBSVisitor visitor,
|
||||
void *closureP, Size closureS)
|
||||
{
|
||||
SplayTree tree;
|
||||
SplayTree splay;
|
||||
CBSIterateClosure closure;
|
||||
|
||||
AVERT(CBS, cbs);
|
||||
cbsEnter(cbs);
|
||||
AVER(FUNCHECK(visitor));
|
||||
|
||||
tree = treeOfCBS(cbs);
|
||||
splay = cbsSplay(cbs);
|
||||
/* .splay-iterate.slow: We assume that splay tree iteration does */
|
||||
/* searches and meter it. */
|
||||
METER_ACC(cbs->treeSearch, cbs->treeSize);
|
||||
|
|
@ -741,7 +741,7 @@ void CBSIterate(CBS cbs, CBSVisitor visitor,
|
|||
closure.iterate = visitor;
|
||||
closure.closureP = closureP;
|
||||
closure.closureS = closureS;
|
||||
(void)TreeTraverse(SplayTreeRoot(tree), tree->compare, tree->nodeKey,
|
||||
(void)TreeTraverse(SplayTreeRoot(splay), splay->compare, splay->nodeKey,
|
||||
cbsIterateVisit, &closure, 0);
|
||||
|
||||
cbsLeave(cbs);
|
||||
|
|
@ -828,7 +828,7 @@ Bool CBSFindFirst(Range rangeReturn, Range oldRangeReturn,
|
|||
CBS cbs, Size size, FindDelete findDelete)
|
||||
{
|
||||
Bool found;
|
||||
Tree node;
|
||||
Tree tree;
|
||||
|
||||
AVERT(CBS, cbs);
|
||||
cbsEnter(cbs);
|
||||
|
|
@ -841,12 +841,12 @@ Bool CBSFindFirst(Range rangeReturn, Range oldRangeReturn,
|
|||
AVERT(FindDelete, findDelete);
|
||||
|
||||
METER_ACC(cbs->treeSearch, cbs->treeSize);
|
||||
found = SplayFindFirst(&node, treeOfCBS(cbs), &cbsTestNode,
|
||||
found = SplayFindFirst(&tree, cbsSplay(cbs), &cbsTestNode,
|
||||
&cbsTestTree, NULL, size);
|
||||
if (found) {
|
||||
CBSBlock block;
|
||||
RangeStruct range;
|
||||
block = cbsBlockOfNode(node);
|
||||
block = cbsBlockOfTree(tree);
|
||||
AVER(CBSBlockSize(block) >= size);
|
||||
RangeInit(&range, CBSBlockBase(block), CBSBlockLimit(block));
|
||||
AVER(RangeSize(&range) >= size);
|
||||
|
|
@ -869,13 +869,13 @@ typedef struct cbsTestNodeInZonesClosureStruct {
|
|||
Addr limit;
|
||||
} cbsTestNodeInZonesClosureStruct, *cbsTestNodeInZonesClosure;
|
||||
|
||||
static Bool cbsTestNodeInZones(SplayTree tree, Tree node,
|
||||
static Bool cbsTestNodeInZones(SplayTree splay, Tree tree,
|
||||
void *closureP, Size closureSize)
|
||||
{
|
||||
CBSBlock block = cbsBlockOfNode(node);
|
||||
CBSBlock block = cbsBlockOfTree(tree);
|
||||
cbsTestNodeInZonesClosure closure = closureP;
|
||||
|
||||
UNUSED(tree);
|
||||
UNUSED(splay);
|
||||
AVER(closureSize == sizeof(cbsTestNodeInZonesClosureStruct));
|
||||
UNUSED(closureSize);
|
||||
|
||||
|
|
@ -886,13 +886,13 @@ static Bool cbsTestNodeInZones(SplayTree tree, Tree node,
|
|||
closure->arena, closure->zoneSet, closure->size);
|
||||
}
|
||||
|
||||
static Bool cbsTestTreeInZones(SplayTree tree, Tree node,
|
||||
static Bool cbsTestTreeInZones(SplayTree splay, Tree tree,
|
||||
void *closureP, Size closureSize)
|
||||
{
|
||||
CBSBlock block = cbsBlockOfNode(node);
|
||||
CBSBlock block = cbsBlockOfTree(tree);
|
||||
cbsTestNodeInZonesClosure closure = closureP;
|
||||
|
||||
UNUSED(tree);
|
||||
UNUSED(splay);
|
||||
AVER(closureSize == sizeof(cbsTestNodeInZonesClosureStruct));
|
||||
UNUSED(closureSize);
|
||||
|
||||
|
|
@ -904,7 +904,7 @@ Res CBSFindInZones(Range rangeReturn, Range oldRangeReturn,
|
|||
CBS cbs, Size size,
|
||||
ZoneSet zoneSet, Bool high)
|
||||
{
|
||||
Tree node;
|
||||
Tree tree;
|
||||
cbsTestNodeInZonesClosureStruct closure;
|
||||
Res res;
|
||||
CBSFindMethod cbsFind;
|
||||
|
|
@ -939,11 +939,11 @@ Res CBSFindInZones(Range rangeReturn, Range oldRangeReturn,
|
|||
closure.arena = cbs->arena;
|
||||
closure.zoneSet = zoneSet;
|
||||
closure.size = size;
|
||||
if (splayFind(&node, treeOfCBS(cbs),
|
||||
if (splayFind(&tree, cbsSplay(cbs),
|
||||
cbsTestNodeInZones,
|
||||
cbsTestTreeInZones,
|
||||
&closure, sizeof(closure))) {
|
||||
CBSBlock block = cbsBlockOfNode(node);
|
||||
CBSBlock block = cbsBlockOfTree(tree);
|
||||
RangeStruct rangeStruct, oldRangeStruct;
|
||||
|
||||
AVER(CBSBlockBase(block) <= closure.base);
|
||||
|
|
@ -971,7 +971,7 @@ Bool CBSFindLast(Range rangeReturn, Range oldRangeReturn,
|
|||
CBS cbs, Size size, FindDelete findDelete)
|
||||
{
|
||||
Bool found;
|
||||
Tree node;
|
||||
Tree tree;
|
||||
|
||||
AVERT(CBS, cbs);
|
||||
cbsEnter(cbs);
|
||||
|
|
@ -984,12 +984,12 @@ Bool CBSFindLast(Range rangeReturn, Range oldRangeReturn,
|
|||
AVERT(FindDelete, findDelete);
|
||||
|
||||
METER_ACC(cbs->treeSearch, cbs->treeSize);
|
||||
found = SplayFindLast(&node, treeOfCBS(cbs), &cbsTestNode,
|
||||
found = SplayFindLast(&tree, cbsSplay(cbs), &cbsTestNode,
|
||||
&cbsTestTree, NULL, size);
|
||||
if (found) {
|
||||
CBSBlock block;
|
||||
RangeStruct range;
|
||||
block = cbsBlockOfNode(node);
|
||||
block = cbsBlockOfTree(tree);
|
||||
AVER(CBSBlockSize(block) >= size);
|
||||
RangeInit(&range, CBSBlockBase(block), CBSBlockLimit(block));
|
||||
AVER(RangeSize(&range) >= size);
|
||||
|
|
@ -1017,19 +1017,19 @@ Bool CBSFindLargest(Range rangeReturn, Range oldRangeReturn,
|
|||
AVER(cbs->fastFind);
|
||||
AVERT(FindDelete, findDelete);
|
||||
|
||||
if (!SplayTreeIsEmpty(treeOfCBS(cbs))) {
|
||||
if (!SplayTreeIsEmpty(cbsSplay(cbs))) {
|
||||
RangeStruct range;
|
||||
CBSBlock block;
|
||||
Tree node = TreeEMPTY; /* suppress "may be used uninitialized" */
|
||||
Tree tree = TreeEMPTY; /* suppress "may be used uninitialized" */
|
||||
Size maxSize;
|
||||
|
||||
maxSize = cbsBlockOfNode(SplayTreeRoot(treeOfCBS(cbs)))->maxSize;
|
||||
maxSize = cbsBlockOfTree(SplayTreeRoot(cbsSplay(cbs)))->maxSize;
|
||||
if (maxSize >= size) {
|
||||
METER_ACC(cbs->treeSearch, cbs->treeSize);
|
||||
found = SplayFindFirst(&node, treeOfCBS(cbs), &cbsTestNode,
|
||||
found = SplayFindFirst(&tree, cbsSplay(cbs), &cbsTestNode,
|
||||
&cbsTestTree, NULL, maxSize);
|
||||
AVER(found); /* maxSize is exact, so we will find it. */
|
||||
block = cbsBlockOfNode(node);
|
||||
block = cbsBlockOfTree(tree);
|
||||
AVER(CBSBlockSize(block) >= maxSize);
|
||||
RangeInit(&range, CBSBlockBase(block), CBSBlockLimit(block));
|
||||
AVER(RangeSize(&range) >= maxSize);
|
||||
|
|
@ -1067,7 +1067,7 @@ Res CBSDescribe(CBS cbs, mps_lib_FILE *stream)
|
|||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
res = SplayTreeDescribe(treeOfCBS(cbs), stream, &cbsSplayNodeDescribe);
|
||||
res = SplayTreeDescribe(cbsSplay(cbs), stream, &cbsSplayNodeDescribe);
|
||||
if (res != ResOK) return res;
|
||||
|
||||
res = METER_WRITE(cbs->treeSearch, stream);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue