...
Code Block | ||||
---|---|---|---|---|
| ||||
#define __STDC_WANT_LIB_EXT1__ 1
#include <stdlib.h>
errno_t f(void) {
png_charp chunkdata;
chunkdata = (png_charp)png_malloc(png_ptr, length + 1);
/* ... */
return 0;
} |
...
Code Block | ||||
---|---|---|---|---|
| ||||
#define __STDC_WANT_LIB_EXT1__ 1
#include <stdlib.h>
errno_t f(void) {
png_charp chunkdata;
chunkdata = (png_charp)png_malloc(png_ptr, length + 1);
if (NULL == chunkdata) {
return ENOMEM; /* Indicate failure */
}
/* ... */
return 0;
} |
...
Code Block | ||||
---|---|---|---|---|
| ||||
#include <string.h>
#define __STDC_WANT_LIB_EXT1__ 1
#include <stdlib.h>
errno_t f(void) {
size_t size = strlen(input_str)+1;
str = (char *)malloc(size);
memcpy(str, input_str, size);
/* ... */
free(str);
str = NULL;
return 0;
} |
...
Code Block | ||||
---|---|---|---|---|
| ||||
#include <string.h>
#define __STDC_WANT_LIB_EXT1__ 1
#include <stdlib.h>
errno_t f(void) {
size_t size = strlen(input_str)+1;
str = (char *)malloc(size);
if (NULL == str) {
return ENOMEM; /* Indicate allocation failure */
}
memcpy(str, input_str, size);
/* ... */
free(str);
str = NULL;
/* ... */
return 0;
} |
...