diff --git a/src/gallium/auxiliary/hud/hud_cpufreq.c b/src/gallium/auxiliary/hud/hud_cpufreq.c index 4501bbb..f425fc6 100644 --- a/src/gallium/auxiliary/hud/hud_cpufreq.c +++ b/src/gallium/auxiliary/hud/hud_cpufreq.c @@ -57,6 +57,7 @@ struct cpufreq_info char sysfs_filename[128]; uint64_t KHz; uint64_t last_time; + int users; }; static int gcpufreq_count = 0; @@ -116,8 +117,10 @@ static void free_query_data(void *p) { struct cpufreq_info *cfi = (struct cpufreq_info *)p; - list_del(&cfi->list); - FREE(cfi); + if (--cfi->users == 0) { + list_del(&cfi->list); + FREE(cfi); + } } /** @@ -159,6 +162,7 @@ hud_cpufreq_graph_install(struct hud_pane *pane, int cpu_index, return; } + cfi->users++; gr->query_data = cfi; gr->query_new_value = query_cfi_load; diff --git a/src/gallium/auxiliary/hud/hud_diskstat.c b/src/gallium/auxiliary/hud/hud_diskstat.c index b248baf..5ae4b24 100644 --- a/src/gallium/auxiliary/hud/hud_diskstat.c +++ b/src/gallium/auxiliary/hud/hud_diskstat.c @@ -73,6 +73,7 @@ struct diskstat_info char sysfs_filename[128]; uint64_t last_time; struct stat_s last_stat; + int users; }; /* TODO: We don't handle dynamic block device / partition @@ -165,9 +166,11 @@ query_dsi_load(struct hud_graph *gr) static void free_query_data(void *p) { - struct diskstat_info *nic = (struct diskstat_info *) p; - list_del(&nic->list); - FREE(nic); + struct diskstat_info *dsi = (struct diskstat_info *) p; + if (--dsi->users == 0) { + list_del(&dsi->list); + FREE(dsi); + } } /** @@ -205,6 +208,7 @@ hud_diskstat_graph_install(struct hud_pane *pane, const char *dev_name, else return; + dsi->users++; gr->query_data = dsi; gr->query_new_value = query_dsi_load; diff --git a/src/gallium/auxiliary/hud/hud_nic.c b/src/gallium/auxiliary/hud/hud_nic.c index fb6b8c0..27b0587 100644 --- a/src/gallium/auxiliary/hud/hud_nic.c +++ b/src/gallium/auxiliary/hud/hud_nic.c @@ -59,6 +59,7 @@ struct nic_info char throughput_filename[128]; uint64_t last_time; uint64_t last_nic_bytes; + int users; }; /* TODO: We don't handle dynamic NIC arrival or removal. @@ -238,8 +239,10 @@ static void free_query_data(void *p) { struct nic_info *nic = (struct nic_info *) p; - list_del(&nic->list); - FREE(nic); + if (--nic->users == 0) { + list_del(&nic->list); + FREE(nic); + } } /** @@ -281,6 +284,7 @@ hud_nic_graph_install(struct hud_pane *pane, const char *nic_name, else return; + nic->users++; gr->query_data = nic; gr->query_new_value = query_nic_load;