]> granicus.if.org Git - graphviz/commitdiff
replace a malloc array allocation with calloc
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 7 Nov 2020 16:37:45 +0000 (08:37 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 14 Nov 2020 01:44:26 +0000 (17:44 -0800)
This can be more efficient for large allocations and is generally cleaner code.

lib/pathplan/triang.c

index cb7811cd7bc1c62d877aa83fe33a9cf6be45e660..7159f35d86ca373fe894cf4cff05fda3117ec854 100644 (file)
@@ -62,7 +62,7 @@ int Ptriangulate(Ppoly_t * polygon, void (*fn) (void *, Ppoint_t *),
 
     pointn = polygon->pn;
 
-    pointp = malloc(pointn * sizeof(Ppoint_t *));
+    pointp = calloc(pointn, sizeof(Ppoint_t *));
 
     for (i = 0; i < pointn; i++)
        pointp[i] = &(polygon->ps[i]);