...
Code Block | ||
---|---|---|
| ||
size_t nsize; /* initialize nsize */ char *p2; char *p = (char *)malloc(100); if (p == NULL) { /* Handle Error */ } /* ... */ if ((p2 = (char *)realloc(p, nsize)) == NULL) { free(p); p = NULL; return NULL; } p = p2; |
...
Code Block | ||
---|---|---|
| ||
size_t nsize;
/* initialize nsize */
char *p2;
char *p = (char *)malloc(100);
if (p == NULL) {
/* Handle Error */
}
/* ... */
p2 = NULL;
if (nsize != 0) {
p2 = (char *)realloc(p, nsize);
}
if (p2 == NULL) {
free(p);
p = NULL;
return NULL;
}
p = p2;
|
...