Commit f0463734 authored by Scott Kaplan's avatar Scott Kaplan
Browse files

Graded feedback.

parent 0690a224
......@@ -237,6 +237,8 @@ void* malloc (size_t size) {
// pad the address for double word alignment
// since the header is 32 bytes, if we align for the header
// then the block will be double word aligned as well
// EE: 16 additional byte oversight
// EE: Also, probably better to not assume anything about sizes for code expandability, otherwise, we're just lucky that the header is 32 bytes.
free_addr = free_addr + (16 - free_addr % 16);
// create a pointer for the header at the next free address space
rm -rf *.o *.so memtest
gcc -std=gnu99 -ggdb -Wall -c bf-alloc.c
gcc -std=gnu99 -ggdb -Wall -c safeio.c
gcc -std=gnu99 -ggdb -Wall -fPIC -shared -o bf-alloc.o safeio.o
gcc -std=gnu99 -ggdb -Wall -o memtest memtest.c
Grade: A
EE: Great work! Check comments for small dw-alignment oversights.
\ No newline at end of file
allocate 3 blocks of size 24, 19, 32 to x,y,z respectively.
x = 0x7fc6859b3060
y = 0x7fc6859b30a0
z = 0x7fc6859b30e0
reallocate x to blocks of size 20 and 30 and store in a,b respectively.
a should result in same block as x and b should allocate a new block.
a = 0x7fc6859b3060
b = 0x7fc6859b3130
After the realloc(x, 30) call, the original block of size 24 is freed and its content are reallocated to a block of size 30.
This should put the block of size 24 on the free block LL.
Allocate a block of size 19 (less than 24) using malloc and store it in c.
c should have the same address that x originally had.
c = 0x7fc6859b3060
free blocks c,y,z to push blocks of sizes 24,19,32 onto the free block list
Allocate a block of size 23 using malloc().
It should take the block previously pointed to by c off the free list and allocate it to d.
d = 0x7fc6859b3060
Allocate a block of size 22 using malloc().
The block of size 24 should no longer be on the free block list.
So the block of size 32 previously pointed to by z should be allocated.
e = 0x7fc6859b30e0
q misaligned as expected (sanity check)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment