Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFCCCC
size_t num_elements;

/* =initialize get_size();num_elements to the number of elements needed */

long *buffer = calloc(num_elements, sizeof(long));
if (buffer == NULL) {
  /* handle error condition */
}
/*...*/
free(buffer);
buffer = NULL; 

...

Code Block
bgColor#ccccff
long *buffer;
size_t num_elements;

/* =initialize calc_size();num_elements to the number of elements needed */

if (num_elements > SIZE_MAX/sizeof(long)) {
  /* handle error condition */
}
buffer = calloc(num_elements, sizeof(long));
if (buffer == NULL) {
  /* handle error condition */
}

...