Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added null pointer exception to intro

...

A similar situation arises when realloc() is supplied a pointer to nondynamically allocated memory. The realloc() function is used to resize a block of dynamic memory. If realloc() is supplied a pointer to memory not allocated by a memory allocation function, such as malloc(), the program may terminate abnormally.

This rule does not apply to null pointers. The standard officially declares that when given a null pointer, free() does nothing.

Noncompliant Code Example

...