Evaluate resize guarantees and aliases

A C program has a live allocation for 9 integer elements, all initialized, and p points to its beginning. The program creates saved as an alias, another pointer referring to the same allocation, then executes this fragment. The requested byte count is positive and representable. Select every statement guaranteed by C's allocation rules.


C
int *saved = p;
int *tmp = realloc(p, 16 * sizeof *p);
if (tmp != NULL) {
    p = tmp;
}


The pointer variables p and saved both refer to one allocation before resizing.


Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Dynamic Memory Questions: