
Write mem_resize, which moves a heap block of old_size bytes into a new block of new_size bytes and keeps its leading bytes.
p = malloc(4); /* 'A','B','C','D' */ q = mem_resize(p, 4, 8);first 4 bytes of q: ABCDp = malloc(8); /* 'A'..'H' */ q = mem_resize(p, 8, 4);first 4 bytes of q: ABCDq = mem_resize(NULL, 0, 6); /* like malloc(6) */q is a fresh 6-byte blockmem-resize.cmallocfree<stdlib.h>declares malloc and free<stddef.h>defines size_tStandard C library
Implements the contract of a function from the standard C library.

Run the tests to grade your code
Write mem_resize, which moves a heap block of old_size bytes into a new block of new_size bytes and keeps its leading bytes.
p = malloc(4); /* 'A','B','C','D' */ q = mem_resize(p, 4, 8);first 4 bytes of q: ABCDp = malloc(8); /* 'A'..'H' */ q = mem_resize(p, 8, 4);first 4 bytes of q: ABCDq = mem_resize(NULL, 0, 6); /* like malloc(6) */q is a fresh 6-byte blockmem-resize.cmallocfree<stdlib.h>declares malloc and free<stddef.h>defines size_tStandard C library
Implements the contract of a function from the standard C library.

Run the tests to grade your code
Memory will appear here