From: Matthew Fernandez Date: Mon, 2 Jan 2023 02:39:27 +0000 (-0800) Subject: sfdpgen spring_maxent_embedding: use an agxbuf instead of 'sprintf' X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8244b9408d6717bc6b15ede031d6ccfcd39805e8;p=graphviz sfdpgen spring_maxent_embedding: use an agxbuf instead of 'sprintf' This leads to less manual memory management and fewer problems to think about. Gitlab: #1950 --- diff --git a/lib/sfdpgen/spring_electrical.c b/lib/sfdpgen/spring_electrical.c index b06767898..caf32a7d2 100644 --- a/lib/sfdpgen/spring_electrical.c +++ b/lib/sfdpgen/spring_electrical.c @@ -1170,10 +1170,10 @@ static void spring_maxent_embedding(int dim, SparseMatrix A0, SparseMatrix D, sp #ifdef DEBUG_0 { FILE *f; - char fname[10000]; - strcpy(fname,"/tmp/graph_layout_0_"); - sprintf(&(fname[strlen(fname)]), "%d",n); - f = fopen(fname,"w"); + agxbuf fname = {0}; + agxbprint(&fname, "/tmp/graph_layout_0_%d", n); + f = fopen(agxbuse(&fname), "w"); + agxbfree(&fname); export_embedding(f, dim, A, x, NULL); fclose(f); }