Skip to content

Commit ead0b01

Browse files
committed
MINOR: activity/memprofile: use resolve_dso_name() for the DSO summary
Let's simplify the code by making use of this simpler and sometimes more efficient variant.
1 parent 670507a commit ead0b01

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

src/activity.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,29 +1146,19 @@ static int cli_io_handler_show_profiling(struct appctx *appctx)
11461146
*/
11471147
for (i = max = 0; i < max_lines; i++) {
11481148
struct memprof_stats *entry = &tmp_memstats[i];
1149-
char *p;
11501149

11511150
if (!entry->alloc_calls && !entry->free_calls)
11521151
continue;
11531152

11541153
chunk_reset(name_buffer);
11551154
if (!entry->caller)
1156-
chunk_printf(name_buffer, "other:");
1157-
else
1158-
resolve_sym_name(name_buffer, "", entry->caller);
1159-
1160-
/* figure the DSO name (before colon) otherwise "*program*" */
1161-
p = strchr(name_buffer->area, ':');
1162-
if (p) {
1163-
*p = 0;
1164-
p = name_buffer->area;
1165-
}
1155+
chunk_printf(name_buffer, "other");
11661156
else
1167-
p = "*program*";
1157+
resolve_dso_name(name_buffer, "", entry->caller);
11681158

11691159
/* look it up among known names (0..max) */
11701160
for (j = 0; j < max; j++) {
1171-
if (tmp_memstats[j].info && strcmp(p, tmp_memstats[j].info) == 0)
1161+
if (tmp_memstats[j].info && strcmp(name_buffer->area, tmp_memstats[j].info) == 0)
11721162
break;
11731163
}
11741164

@@ -1181,7 +1171,7 @@ static int cli_io_handler_show_profiling(struct appctx *appctx)
11811171
if (j != i) // set max to keep min caller's address
11821172
tmp_memstats[j].caller = (void*)-1;
11831173

1184-
tmp_memstats[j].info = strdup(p); // may fail, but checked when used
1174+
tmp_memstats[j].info = strdup(name_buffer->area); // may fail, but checked when used
11851175
tmp_memstats[j].alloc_calls = entry->alloc_calls;
11861176
tmp_memstats[j].alloc_tot = entry->alloc_tot;
11871177
if ((1UL << entry->method) & MEMPROF_FREE_MASK) {

0 commit comments

Comments
 (0)