From c5c3cc1b2e8d0e796d01f2d3d2ef0c6d5bfae86c Mon Sep 17 00:00:00 2001 From: Alex Apostolescu Date: Fri, 3 Nov 2023 16:01:32 +0200 Subject: [PATCH] asg/mem-alloc: Remove block expansion from realloc-split-one-block Do not test block expansion in realloc-split-one-block. Signed-off-by: Alex Apostolescu --- .../tests/ref/test-realloc-split-one-block.ref | 3 --- .../tests/snippets/test-realloc-split-one-block.c | 12 +++++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/content/assignments/memory-allocator/tests/ref/test-realloc-split-one-block.ref b/content/assignments/memory-allocator/tests/ref/test-realloc-split-one-block.ref index b0fbce8ba4..5fc2efc25f 100644 --- a/content/assignments/memory-allocator/tests/ref/test-realloc-split-one-block.ref +++ b/content/assignments/memory-allocator/tests/ref/test-realloc-split-one-block.ref @@ -10,8 +10,6 @@ os_realloc (['0', '4096']) os_realloc (['0', '2048']) = HeapStart + 0x1f0c0 os_realloc (['0', '1024']) = HeapStart + 0x1f8e0 os_realloc (['0', '512']) = HeapStart + 0x1fd00 -os_realloc (['0', '256']) = HeapStart + 0x1ff20 - brk (['HeapStart + 0x20020']) = HeapStart + 0x20020 os_realloc (['HeapStart + 0x20', '0']) = 0 os_realloc (['HeapStart + 0x18060', '32798']) = HeapStart + 0x20 os_realloc (['HeapStart + 0x1c080', '16414']) = HeapStart + 0x8060 @@ -27,5 +25,4 @@ os_free (['HeapStart + 0xc0a0']) os_free (['HeapStart + 0xe0e0']) = os_free (['HeapStart + 0xf120']) = os_free (['HeapStart + 0xf960']) = -os_free (['HeapStart + 0x1ff20']) = +++ exited (status 0) +++ diff --git a/content/assignments/memory-allocator/tests/snippets/test-realloc-split-one-block.c b/content/assignments/memory-allocator/tests/snippets/test-realloc-split-one-block.c index 4bdf95217d..280e08d5f5 100644 --- a/content/assignments/memory-allocator/tests/snippets/test-realloc-split-one-block.c +++ b/content/assignments/memory-allocator/tests/snippets/test-realloc-split-one-block.c @@ -2,13 +2,15 @@ #include "test-utils.h" +#define NUM_SIZES 8 + int main(void) { - int sizes[9]; - void *prealloc_ptr, *ptrs[9]; + int sizes[NUM_SIZES]; + void *prealloc_ptr, *ptrs[NUM_SIZES]; /* Init sizes */ - for (int i = 0; i < 9; i++) + for (int i = 0; i < NUM_SIZES; i++) sizes[i] = MMAP_THRESHOLD / (1 << (i + 1)); /* Create a free block */ @@ -17,7 +19,7 @@ int main(void) os_free(prealloc_ptr); /* Split the chunk multiple times */ - for (int i = 0; i < 9; i++) + for (int i = 0; i < NUM_SIZES; i++) ptrs[i] = os_realloc_checked(NULL, sizes[i]); /* Free the first ptr and reallocate the others */ @@ -28,7 +30,7 @@ int main(void) ptrs[i] = os_realloc_checked(ptrs[i], sizes[i-1] + 30); /* Cleanup */ - for (int i = 0; i < 9; i++) + for (int i = 0; i < NUM_SIZES; i++) os_free(ptrs[i]); return 0;