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

Modern Database Management

Authors: Donald A. Carpenter Fred R. McFadden

1st Edition

8178088045, 978-8178088044

More Books

Students also viewed these Databases questions

Question

Evaluate 1 0.75 coth 2x dx.

Answered: 1 week ago

Question

Describe how to train managers to coach employees. page 404

Answered: 1 week ago

Question

Discuss the steps in the development planning process. page 381

Answered: 1 week ago