Workaround automatic free() when resizing to 0
This commit is contained in:
parent
018a88e1e9
commit
02a877d0bf
|
@ -99,6 +99,8 @@ int buffer_set_size(Buffer * buffer, size_t size)
|
||||||
{
|
{
|
||||||
char * p;
|
char * p;
|
||||||
|
|
||||||
|
if(size == 0) /* XXX workaround to avoid freeing the data */
|
||||||
|
size++;
|
||||||
if((p = realloc(buffer->data, size)) == NULL)
|
if((p = realloc(buffer->data, size)) == NULL)
|
||||||
return error_set_code(1, "%s", strerror(errno));
|
return error_set_code(1, "%s", strerror(errno));
|
||||||
buffer->data = p;
|
buffer->data = p;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user