Versions Compared

Key

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

...

Code Block
bgColor#FFCCCC
size_t num_elements;

/* initialize num_elements to the number of elements needed */

long *buffer = (long *)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 num_elements to the number of elements needed */

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

...