57 }
58
59 static void
60 setup_demangled_names(void)
61 {
62 const char *p;
63 char *nbp, *nbe, *namebuf;
64 size_t cur_len = 0, namebuf_sz = BUCKET_SZ;
65 size_t i, namelen;
66
67 if ((namebuf = malloc(namebuf_sz)) == NULL) {
68 (void) fprintf(stderr, "%s: can't allocate %d bytes\n",
69 cmdname, namebuf_sz);
70 exit(ERR_MEMORY);
71 }
72
73 nbp = namebuf;
74 nbe = namebuf + namebuf_sz;
75
76 for (i = 0; i < total_funcs; i++) {
77 if ((p = conv_demangle_name(profsym[i].name)) == NULL)
78 continue;
79
80 namelen = strlen(p);
81 if ((nbp + namelen + 1) > nbe) {
82 namebuf_sz += BUCKET_SZ;
83 namebuf = realloc(namebuf, namebuf_sz);
84 if (namebuf == NULL) {
85 (void) fprintf(stderr,
86 "%s: can't alloc %d bytes\n",
87 cmdname, BUCKET_SZ);
88 exit(ERR_MEMORY);
89 }
90
91 nbp = namebuf + cur_len;
92 nbe = namebuf + namebuf_sz;
93 }
94
95 (void) strcpy(nbp, p);
96 profsym[i].demangled_name = nbp;
97
98 nbp += namelen + 1;
99 cur_len += namelen + 1;
100 }
101 }
102
103 int
104 cmp_by_time(const void *arg1, const void *arg2)
105 {
106 profrec_t *a = (profrec_t *)arg1;
107 profrec_t *b = (profrec_t *)arg2;
108
109 if (a->percent_time > b->percent_time)
110 return (-1);
111 else if (a->percent_time < b->percent_time)
112 return (1);
113 else
114 return (0);
115 }
116
117 int
118 cmp_by_ncalls(const void *arg1, const void *arg2)
119 {
|
57 }
58
59 static void
60 setup_demangled_names(void)
61 {
62 const char *p;
63 char *nbp, *nbe, *namebuf;
64 size_t cur_len = 0, namebuf_sz = BUCKET_SZ;
65 size_t i, namelen;
66
67 if ((namebuf = malloc(namebuf_sz)) == NULL) {
68 (void) fprintf(stderr, "%s: can't allocate %d bytes\n",
69 cmdname, namebuf_sz);
70 exit(ERR_MEMORY);
71 }
72
73 nbp = namebuf;
74 nbe = namebuf + namebuf_sz;
75
76 for (i = 0; i < total_funcs; i++) {
77 p = conv_demangle_name(profsym[i].name);
78 if (p == profsym[i].name)
79 continue;
80
81 namelen = strlen(p);
82 if ((nbp + namelen + 1) > nbe) {
83 namebuf_sz += BUCKET_SZ;
84 namebuf = realloc(namebuf, namebuf_sz);
85 if (namebuf == NULL) {
86 (void) fprintf(stderr,
87 "%s: can't alloc %d bytes\n",
88 cmdname, BUCKET_SZ);
89 exit(ERR_MEMORY);
90 }
91
92 nbp = namebuf + cur_len;
93 nbe = namebuf + namebuf_sz;
94 }
95
96 (void) strcpy(nbp, p);
97 profsym[i].demangled_name = nbp;
98
99 nbp += namelen + 1;
100 cur_len += namelen + 1;
101 free((void *)p);
102 }
103 }
104
105 int
106 cmp_by_time(const void *arg1, const void *arg2)
107 {
108 profrec_t *a = (profrec_t *)arg1;
109 profrec_t *b = (profrec_t *)arg2;
110
111 if (a->percent_time > b->percent_time)
112 return (-1);
113 else if (a->percent_time < b->percent_time)
114 return (1);
115 else
116 return (0);
117 }
118
119 int
120 cmp_by_ncalls(const void *arg1, const void *arg2)
121 {
|