From e49798d967361536af9339202a3306fe1347d93f Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 25 Oct 2004 23:39:46 +0000 Subject: [PATCH 1/1] Add some more correctness assertions to free(). (I did some basic testing on this.) --- src/threads/malloc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/threads/malloc.c b/src/threads/malloc.c index 487e938..2077354 100644 --- a/src/threads/malloc.c +++ b/src/threads/malloc.c @@ -228,8 +228,16 @@ static struct arena * block_to_arena (struct block *b) { struct arena *a = pg_round_down (b); + + /* Check that the arena is valid. */ ASSERT (a != NULL); ASSERT (a->magic == ARENA_MAGIC); + + /* Check that the block is properly aligned for the arena. */ + ASSERT (a->desc == NULL + || (pg_ofs (b) - sizeof *a) % a->desc->block_size == 0); + ASSERT (a->desc != NULL || pg_ofs (b) == sizeof *a); + return a; } -- 2.30.2