Tuesday, January 3, 2012

Dynamic Memory allocation --1

void *ptr;
size_t size = BUFSIZ;
 
ptr = malloc(size);
 
/* some further execution happens here... */
 
/* now the buffer size needs to be doubled */

size *= 2;
ptr = realloc(ptr, size);
What is potential error in these set of c statements?

No comments:

Post a Comment