]> granicus.if.org Git - graphviz/commitdiff
stack-allocate a statically sized buffer
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 24 Apr 2021 04:16:27 +0000 (21:16 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 14 May 2021 00:03:36 +0000 (17:03 -0700)
1000 bytes is not a lot to allocate on the stack on a modern platform.

lib/sparse/DotIO.c

index 2d6dc86e1c84cfed21ee1b270d719f77714fff5e..1a4e0ee1f83327610b8299b9ab6da2ceec1826f8 100644 (file)
@@ -423,14 +423,13 @@ makeDotGraph (SparseMatrix A, char *name, int dim, real *x, int with_color, int
   Agnode_t** arr = N_NEW (A->m, Agnode_t*);
   real *color = NULL;
   char cstring[8];
-  char *label_string;
+  char label_string[1000];
 
   if (!name){
     name = "stdin";
   } else {
     name = strip_dir(name);
   }
-  label_string = MALLOC(sizeof(char)*1000);
 
   if (SparseMatrix_known_undirected(A)){
     g = agopen ("G", Agundirected, 0);
@@ -587,7 +586,6 @@ makeDotGraph (SparseMatrix A, char *name, int dim, real *x, int with_color, int
   
   FREE(color);
   FREE (arr);
-  FREE(label_string);
   return g;
 }