Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: wordsmithed exception

...

Code Block
bgColor#ccccff
langc
#include <stdlib.h>

const size_t BUFFER_SIZE = 32;

int f(void) {
  char *text_buffer = (char *)malloc(BUFFER_SIZE); 
  if (text_buffer == NULL) {
    return -1;
  }
 
  free(text_buffer);
  return 0;
}

Exceptions

MEM31-EX1: It is permissible not to free memory that Allocated memory does not need to be freed if it is used throughout the lifetime of the program. The following code example illustrates a pointer object that stores the return value from malloc() that is stored in a static variable.

...