]> granicus.if.org Git - graphviz/commitdiff
abbreviate 'agxbdisown' usage and remove 'agxbfree' calls
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 11 Aug 2022 02:33:00 +0000 (19:33 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 12 Aug 2022 04:27:02 +0000 (21:27 -0700)
As discussed in the previous commit, `agxbfree` following an `agxbdisown` is no
longer necessary.

lib/common/labels.c
lib/common/utils.c
lib/xdot/xdot.c

index ae67f45a84612a2ff0a91bd3d56809b0bb654634..05d8bd498e03377cf35ac87efee8e00c382f30cd 100644 (file)
@@ -286,7 +286,7 @@ void emit_label(GVJ_t * job, emit_state_t emit_state, textlabel_t * lp)
  */
 static char *strdup_and_subst_obj0 (char *str, void *obj, int escBackslash)
 {
-    char c, *s, *newstr;
+    char c, *s;
     char *tp_str = "", *hp_str = "";
     char *g_str = "\\G", *n_str = "\\N", *e_str = "\\E",
        *h_str = "\\H", *t_str = "\\T", *l_str = "\\L";
@@ -385,10 +385,7 @@ static char *strdup_and_subst_obj0 (char *str, void *obj, int escBackslash)
     }
 
     /* extract the final string with replacements applied */
-    newstr = agxbdisown(&buf);
-    agxbfree(&buf);
-
-    return newstr;
+    return agxbdisown(&buf);
 }
 
 /* strdup_and_subst_obj:
index 6b28dcaa311702501d8b2103dcea362e415cf1a9..15d857e8784fef87f0e6e72cfc381418d32f2d1c 100644 (file)
@@ -1426,7 +1426,6 @@ char* htmlEntityUTF8 (char* s, graph_t* g)
 {
     static graph_t* lastg;
     static bool warned;
-    char*  ns;
     unsigned char c;
     unsigned int v;
 
@@ -1498,9 +1497,7 @@ char* htmlEntityUTF8 (char* s, graph_t* g)
                    }
         agxbputc(&xb, (char)c);
     }
-    ns = agxbdisown(&xb);
-    agxbfree(&xb);
-    return ns;
+    return agxbdisown(&xb);
 }
 
 /* latin1ToUTF8:
@@ -1510,7 +1507,6 @@ char* htmlEntityUTF8 (char* s, graph_t* g)
  */
 char* latin1ToUTF8 (char* s)
 {
-    char*  ns;
     agxbuf xb = {0};
     unsigned int  v;
 
@@ -1534,9 +1530,7 @@ char* latin1ToUTF8 (char* s)
            agxbputc(&xb, (char)((v & 0x3F) | 0x80));
        }
     }
-    ns = agxbdisown(&xb);
-    agxbfree(&xb);
-    return ns;
+    return agxbdisown(&xb);
 }
 
 /* utf8ToLatin1:
@@ -1547,7 +1541,6 @@ char* latin1ToUTF8 (char* s)
 char*
 utf8ToLatin1 (char* s)
 {
-    char*  ns;
     agxbuf xb = {0};
     unsigned char c;
     unsigned char outc;
@@ -1562,9 +1555,7 @@ utf8ToLatin1 (char* s)
            agxbputc(&xb, (char)outc);
        }
     }
-    ns = agxbdisown(&xb);
-    agxbfree(&xb);
-    return ns;
+    return agxbdisown(&xb);
 }
 
 bool overlap_node(node_t *n, boxf b)
index fb8b019ac9ab634ad1ab20f0039f25def6028ce1..6defcb2178e46b664675ce55c8fea4d2416085f1 100644 (file)
@@ -739,14 +739,11 @@ static void _printXDot(xdot * x, pf print, void *info, print_op ofn)
 
 char *sprintXDot(xdot * x)
 {
-    char *s;
     char buf[BUFSIZ];
     agxbuf xb;
     agxbinit(&xb, BUFSIZ, buf);
     _printXDot(x, (pf)agxbprint, &xb, printXDot_Op);
-    s = agxbdisown(&xb);
-
-    return s;
+    return agxbdisown(&xb);
 }
 
 void fprintXDot(FILE * fp, xdot * x)