]> granicus.if.org Git - graphviz/commitdiff
pathplan: remove 'mymalloc' wrapper
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 30 Jul 2022 16:21:45 +0000 (09:21 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 5 Aug 2022 13:52:10 +0000 (06:52 -0700)
The calling code does not rely on the semantics of `malloc` returning `NULL`
when called with a 0 size. It unconditionally frees these arrays in `Pobsclose`
so allocations returning a non-`NULL` pointer for 0-sized allocations (which
Glibc typically does) is fine. Maintaining a wrapper that enforces this is
unnecessary.

lib/pathplan/cvt.c

index d2ed716476f2e0c15b5717d7c8ac4996af131a9b..f22bd5d58bcf0b6a6ce1a1998ba9f5ec2e7bc616 100644 (file)
@@ -27,18 +27,6 @@ static void gasp_print_polyline(Ppolyline_t * route);
 static void gasp_print_bezier(Ppolyline_t * route);
 #endif
 
-static void *mymalloc(size_t newsize)
-{
-    void *rv;
-
-    if (newsize > 0)
-       rv = malloc(newsize);
-    else
-       rv = NULL;
-    return rv;
-}
-
-
 vconfig_t *Pobsopen(Ppoly_t ** obs, int n_obs)
 {
     vconfig_t *rv;
@@ -54,10 +42,10 @@ vconfig_t *Pobsopen(Ppoly_t ** obs, int n_obs)
     n = 0;
     for (poly_i = 0; poly_i < n_obs; poly_i++)
        n += obs[poly_i]->pn;
-    rv->P = mymalloc(n * sizeof(Ppoint_t));
-    rv->start = mymalloc((n_obs + 1) * sizeof(int));
-    rv->next = mymalloc(n * sizeof(int));
-    rv->prev = mymalloc(n * sizeof(int));
+    rv->P = malloc(n * sizeof(Ppoint_t));
+    rv->start = malloc((n_obs + 1) * sizeof(int));
+    rv->next = malloc(n * sizeof(int));
+    rv->prev = malloc(n * sizeof(int));
     rv->N = n;
     rv->Npoly = n_obs;