Print this page
libconv

@@ -20,14 +20,14 @@
  */
 
 /*
  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright 2018 Jason King
  */
 
-#pragma ident   "%Z%%M% %I%     %E% SMI"
-
 #include <ctype.h>
 #include <string.h>
 #include <sys/param.h>
 #include <stdlib.h>
 #include "conv.h"

@@ -498,13 +498,10 @@
 {
         const char  *c;
         c = demangled_name(selfp);
 
         if (selfp->name != 0) {
-                if (!Cflag)
-                        (void) printf("%s", selfp->name);
-                else
                         (void) printf("%s", c);
 
 #ifdef DEBUG
                 if (debug & DFNDEBUG)
                         (void) printf("{%d} ", selfp->toporder);

@@ -521,28 +518,30 @@
                 if (selfp->printflag)
                         (void) printf(" [%d]", selfp->index);
                 else
                         (void) printf(" (%d)", selfp->index);
         }
+
+        if (c != selfp->name)
+                free((void *)c);
 }
 
 void
 print_demangled_name(int n, nltype *selfp)
 {
-        char *c;
+        char *c = demangled_name(selfp);
         int i;
 
-        c = selfp->name;
-
-        if (strcmp(c, demangled_name(selfp)) == 0)
+        if (c == selfp->name)
                 return;
-        else {
+
                 (void) printf("\n");
                 for (i = 1; i < n; i++)
                         (void) printf(" ");
                 (void) printf("[%s]", selfp->name);
-        }
+
+        free((void *)c);
 }
 
 void
 sortchildren(nltype *parentp)
 {

@@ -880,23 +879,26 @@
 }
 
 void
 striped_name(char *s, nltype **npp)
 {
-        const char *d;
+        const char *name, *d;
         char *c;
 
         c = (char *)s;
-        d = demangled_name(*npp);
+        name = d = demangled_name(*npp);
 
         while ((*d != '(') && (*d != '\0')) {
                 if (*d != ':')
                         *c++ = *d++;
                 else
                         d++;
         }
         *c = '\0';
+
+        if ((*npp)->name != name)
+                free((void *)name);
 }
 
 /*
  * Checks if the current symbol name is the same as its neighbour and
  * returns TRUE if it is.