...
Code Block | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
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 */
}
|
...