if (mi == NULL)
return -ENOMEM;
- mi_dup = memdup(mi, sizeof(*mi));
- if (!mi_dup)
- goto free_mi;
+ /*
+ * The mi object is released in hists__add_entry_ops,
+ * if it gets sorted out into existing data, so we need
+ * to take the copy now.
+ */
+ mi_dup = mem_info__get(mi);
c2c_decode_stats(&stats, mi);
&al, NULL, NULL, mi,
sample, true);
if (he == NULL)
- goto free_mi_dup;
+ goto free_mi;
c2c_he = container_of(he, struct c2c_hist_entry, he);
c2c_add_stats(&c2c_he->stats, &stats);
mi = mi_dup;
- mi_dup = memdup(mi, sizeof(*mi));
- if (!mi_dup)
- goto free_mi;
-
c2c_hists = he__get_c2c_hists(he, c2c.cl_sort, 2);
if (!c2c_hists)
- goto free_mi_dup;
+ goto free_mi;
he = hists__add_entry_ops(&c2c_hists->hists, &c2c_entry_ops,
&al, NULL, NULL, mi,
sample, true);
if (he == NULL)
- goto free_mi_dup;
+ goto free_mi;
c2c_he = container_of(he, struct c2c_hist_entry, he);
c2c_add_stats(&c2c_he->stats, &stats);
addr_location__put(&al);
return ret;
-free_mi_dup:
- free(mi_dup);
free_mi:
- free(mi);
+ mem_info__put(mi_dup);
+ mem_info__put(mi);
ret = -ENOMEM;
goto out;
}