From: Matthew Fernandez Date: Thu, 2 Sep 2021 01:37:14 +0000 (-0700) Subject: remove an unnecessary use of C string functions in SWIG bindings code X-Git-Tag: 2.49.1~38^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3e5003352e133b55b446ed71a97ebb695d5d2a11;p=graphviz remove an unnecessary use of C string functions in SWIG bindings code --- diff --git a/tclpkg/gv/gv.cpp b/tclpkg/gv/gv.cpp index 9a07d42ae..4af459ae2 100644 --- a/tclpkg/gv/gv.cpp +++ b/tclpkg/gv/gv.cpp @@ -11,6 +11,7 @@ #include #include #include +#include extern "C" { extern void gv_string_writer_init(GVC_t *gvc); @@ -174,16 +175,11 @@ char *getv(Agraph_t *g, char *attr) } static void myagxset(void *obj, Agsym_t *a, char *val) { - int len; - char *hs; - if (strcmp(a->name, "label") == 0 && val[0] == '<') { - len = strlen(val); + size_t len = strlen(val); if (val[len-1] == '>') { - hs = strdup(val+1); - *(hs+len-2) = '\0'; - val = agstrdup_html(agraphof(obj),hs); - free(hs); + std::string hs(val + 1, len - 2); + val = agstrdup_html(agraphof(obj), hs.c_str()); } } agxset(obj, a, val);