Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The following implementation of realloc (language C) is can be seen in the image below: Given this implementation, answer the following questions with respect to
The following implementation of realloc (language C) is can be seen in the image below:
Given this implementation, answer the following questions with respect to the provided information:
void new_realloc(void *oldptr, size t newsz) if (newsz0) free(oldptr); return NULL; // the following is a call to a placeholder function // for internal information managed by the heap allocator size-t move sz bytes-to move(oldptr, news z); if (movesz) /the allocator determined it had space, so // it updated its own records and we just return // the old pointer return oldptr; // if the allocator couldn't leave in place, must malloc and move void *newptr malloc(newsz); if (newptr != NULL && oldptr != NULL) { memcpy(newptr, oldptr, movesz); free(oldptr); return newptrStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started