From: Matthew Fernandez Date: Thu, 11 Aug 2022 02:33:00 +0000 (-0700) Subject: abbreviate 'agxbdisown' usage and remove 'agxbfree' calls X-Git-Tag: 5.0.1~12^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0ed729ab169f00b9cde690903d22aa5728107f21;p=graphviz abbreviate 'agxbdisown' usage and remove 'agxbfree' calls As discussed in the previous commit, `agxbfree` following an `agxbdisown` is no longer necessary. --- diff --git a/lib/common/labels.c b/lib/common/labels.c index ae67f45a8..05d8bd498 100644 --- a/lib/common/labels.c +++ b/lib/common/labels.c @@ -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: diff --git a/lib/common/utils.c b/lib/common/utils.c index 6b28dcaa3..15d857e87 100644 --- a/lib/common/utils.c +++ b/lib/common/utils.c @@ -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) diff --git a/lib/xdot/xdot.c b/lib/xdot/xdot.c index fb8b019ac..6defcb217 100644 --- a/lib/xdot/xdot.c +++ b/lib/xdot/xdot.c @@ -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)