From 3e5003352e133b55b446ed71a97ebb695d5d2a11 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Wed, 1 Sep 2021 18:37:14 -0700 Subject: [PATCH] remove an unnecessary use of C string functions in SWIG bindings code --- tclpkg/gv/gv.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) 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); -- 2.40.0