Since para_malloc() never returns NULL, the error state can only be
zero. Use para_calloc(), skip the zero initializations and kill a
pointless local variable.
static struct membuffer *membuffer_create(void)
{
- const unsigned initial_size = 256;
-
- struct membuffer *buf = para_malloc(sizeof(*buf));
- buf->data = para_malloc(initial_size);
- buf->written = 0;
- buf->allocated = initial_size;
- buf->error = buf->data == 0 ? 1 : 0;
+ struct membuffer *buf = para_calloc(sizeof(*buf));
+ buf->allocated = 256;
+ buf->data = para_malloc(buf->allocated);
return buf;
}