Print this page
cleanup
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 = (char *)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(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.
@@ -1036,17 +1038,20 @@
const char *d = demangled_name(nlp);
if (does_clash(namesortnlp, i, nnames)) {
(void) printf("%6.6s %d:%s\n",
peterbuffer, nlp->module->id, d);
- } else
+ } else {
(void) printf("%6.6s %s\n", peterbuffer,
d);
+ }
- if (d != nlp->name)
+ if (d != nlp->name) {
(void) printf("%6.6s [%s]", "",
nlp->name);
+ free((void *)d);
+ }
} else {
(void) printf("%6.6s ", peterbuffer);
(void) sprintf(peterbuffer, "<cycle %d>",
nlp->cycleno);
(void) printf("%-33.33s", peterbuffer);