Workaround automatic free() when resizing to 0

This commit is contained in:
Pierre Pronchery 2007-11-07 15:08:11 +00:00
parent 018a88e1e9
commit 02a877d0bf

View File

@ -99,6 +99,8 @@ int buffer_set_size(Buffer * buffer, size_t size)
{
char * p;
if(size == 0) /* XXX workaround to avoid freeing the data */
size++;
if((p = realloc(buffer->data, size)) == NULL)
return error_set_code(1, "%s", strerror(errno));
buffer->data = p;