From e85bf87e4a33514e66125547ad8b83c736023ced Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 14 Aug 2021 22:40:00 +0200 Subject: [PATCH] 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. --- mp4.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) 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; } -- 2.39.2