Print this page
libconv
@@ -20,10 +20,12 @@
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright 2018 Jason King
*/
#include "msg.h"
#include "_debug.h"
#include "libld.h"
@@ -340,18 +342,37 @@
* Define name demanglers.
*/
const char *
Dbg_demangle_name(const char *name)
{
+ static char *buf = NULL;
+
if (DBG_NOTCLASS(DBG_C_DEMANGLE))
return (name);
- return (conv_demangle_name(name));
+ free(buf);
+ buf = (char *)conv_demangle_name(name);
+ if (buf == name) {
+ buf = NULL;
+ return (name);
+ }
+
+ return (buf);
}
const char *
Elf_demangle_name(const char *name)
{
- if (DBG_ISDEMANGLE())
- return (conv_demangle_name(name));
+ static char *buf = NULL;
+
+ if (!DBG_ISDEMANGLE())
return (name);
+
+ free(buf);
+ buf = (char *)conv_demangle_name(name);
+ if (buf == name) {
+ buf = NULL;
+ return (name);
+ }
+
+ return (buf);
}