Mail Archives: djgpp-workers/2001/06/02/07:01:58
> From: "Mark E." <snowball3 AT bigfoot DOT com>
> Date: Sun, 27 May 2001 18:24:11 -0400
>
> This patch should be done barring any problems discovered during this review.
On closer look, I see here something that worries me. `malloc' sets
the last bit of the size and endsz fields in the block it allocates:
#define RET(rv) CHECK(rv); ENDSZ(rv) |= 1; rv->size |= 1; return DATA(rv)
(The macro RET is used throughout in `malloc', whenever it returns a
block to the caller.)
This bit is used in `free':
if (! (AFTER(block)->size & 1))
{
CHECK(AFTER(block));
}
if (! (BEFSZ(block) & 1))
{
CHECK(BEFORE(block));
block = merge(BEFORE(block), block, BEFORE(block));
}
CHECK(block);
if (! (AFTER(block)->size & 1))
{
CHECK(AFTER(block));
block = merge(block, AFTER(block), AFTER(block));
}
However, `realloc_inplace' doesn't use the RET macro (it can't), and
doesn't set that LSB either. It simply returns the block it found
with the size and endsz fields intact.
Won't that give us trouble when `free' comes to free the blocks found
by `realloc_inplace'?
- Raw text -