Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Factory Active Database For Enterprise Computing

Authors: Schur, Stephen

1st Edition

0471558443, 9780471558446

More Books

Students also viewed these Databases questions