/*
* Scan the marked blocks for references to other unmarked blocks.
*/
static void
mark_from_heap(void)
{
unsigned int *vp;
header_t *bp, *up;
for (bp = UNTAG(usedp->next); bp != usedp; bp = UNTAG(bp->next)) {
if (!((unsigned int)bp->next & 1))
continue;
for (vp = (unsigned int *)(bp + 1);
vp < (bp + bp->size + 1);
vp++) {
unsigned int v = *vp;
up = UNTAG(bp->next);
do {
if (up != bp &&
up + 1 <= v &&
up + 1 + up->size > v) {
up->next = ((unsigned int) up->next) | 1;
break;
}
} while ((up = UNTAG(up->next)) != bp);
}
}
}