]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
mp4: Simplify membuffer_create().
authorAndre Noll <maan@tuebingen.mpg.de>
Sat, 14 Aug 2021 20:40:00 +0000 (22:40 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Mon, 30 May 2022 19:37:35 +0000 (21:37 +0200)
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

diff --git a/mp4.c b/mp4.c
index 7085e95918b626eb917269c3389db8bb77161130..bdbd3221a47eccede97b706c0c952f67385f6f0f 100644 (file)
--- 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;
 }