Question: Implement malloc() and free() in C without using malloc, realloc, free, or calloc. For malloc() you should allocate a block of memory of size 'a'

Implement malloc() and free() in C without using malloc, realloc, free, or calloc. For malloc() you should allocate a block of memory of size 'a' and return a pointer to the begining of the block. If the function fails to allocate memory, then return a NULL pointer. For free(), you should deallocate space in ememory that was previously allocated with malloc, calloc, realloc and make it open space again. You should not change the value of pointer, just have it pointing at a location that now contains nothing (not a NULL pointer!) If a NULL pointer is passed in, then do nothing.

void *malloc(size_t a) { }

void free(void *ptr) {

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!