From: Andre Noll Date: Sat, 14 Aug 2021 20:40:00 +0000 (+0200) Subject: mp4: Simplify membuffer_create(). X-Git-Tag: v0.7.1~7^2~71 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=e85bf87e4a33514e66125547ad8b83c736023ced;p=paraslash.git mp4: Simplify membuffer_create(). 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. --- diff --git a/mp4.c b/mp4.c index 7085e959..bdbd3221 100644 --- a/mp4.c +++ b/mp4.c @@ -1148,14 +1148,10 @@ struct membuffer { 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; }