Description
Extend the memory allocation example with a segment deallocation function, including a fusion function that merges headers of adjacent segments. The deallocation
function must have the signature:
void myfree(void *p)
The pointer must be verified using the field ”void * ptr” in the header.
You may reuse and adapt code returned by Google, but give credit to and cite your
sources.
Test your software with the provided tester program (tester.c).
Here is a sample execution:
$ ./tester
Initial program break: 0xaea000
*** First test ***
Allocating 1024 bytes
After allocation, program break is: 0xaea428
Allocating 2048 bytes
After allocation, program break is: 0xaeac50
Allocating 4096 bytes
After allocation, program break is: 0xaebc78
Address being freed: 0xaeac78
After freeing, program break is: 0xaeac50
Address being freed: 0xaea450
After freeing, program break is: 0xaea428
Address being freed: 0xaea028
After freeing, program break is: 0xaea000
*** 2nd test ***
Testing freeing invalid address
Program break is: 0xaea000
*** 3rdt test ***
Allocating 1024 bytes
1
After allocation, program break is: 0xaea428
Allocating 2048 bytes
After allocation, program break is: 0xaeac50
Allocating 4096 bytes
After allocation, program break is: 0xaebc78
Address being freed: 0xaea028
After freeing, program break is: 0xaebc78
Address being freed: 0xaea450
After freeing, program break is: 0xaebc78
Address being freed: 0xaeac78
After freeing, program break is: 0xaea000
*** 4th test ***
Final program break is: 0xaea000
Due date: March 18. Submit you work on cuLearn. This exercise must be done in
the C programming language under Linux (make sure it runs on Ubuntu 16.04 64-bit).
Submit a single tar.gz file. Submit source code and makefile. You are responsible for
the completeness of your submission. You are responsible for submitting your work on
time. Submissions that do not compile are not accepted.
2

