]> granicus.if.org Git - graphviz/commitdiff
ccomps: remove an unnecessary code path in getBuf
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 25 Jul 2021 00:26:21 +0000 (17:26 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 27 Jul 2021 14:30:33 +0000 (07:30 -0700)
When len is 0, buf is NULL and thus calling realloc is equivalent to calling
malloc.

cmd/tools/ccomps.c

index 47694632332f7ad962407bab678c857eb8595989..f5c2c6a0bad2abe88339367cfc2a474c0d7b0dc2 100644 (file)
@@ -394,10 +394,7 @@ static char *getBuf(int n)
 
     if (n > len) {
        sz = n + 100;
-       if (len == 0)
-           buf = malloc(sz);
-       else
-           buf = realloc(buf, sz);
+       buf = realloc(buf, sz);
        len = sz;
     }
     return buf;