plugins: Freeing allocated values in hash tables.
cover plugins: Freeing allocated values in hash tables.
A hash table made using ``g_hash_table_new`` requires manually freeing any dynamically allocated keys/values. The two patches in this series fixes this issue in hotblocks and hotpages plugins.
Mahmoud Mandour (2):
plugins/hotblocks: Properly freed the hash table values plugins/hotpages: Properly freed the hash table values
contrib/plugins/hotblocks.c | 3 ++- contrib/plugins/hotpages.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/2 plugins/hotblocks: Properly freed the hash table values
Freed the values stored in the hash table ``hotblocks`` returned by ``g_hash_table_get_values()`` by freeing the sorted list and destroyed the hash table afterward.
--- contrib/plugins/hotblocks.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
contrib/plugins/hotblocks.c +2 -1
@@ -68,10 +68,11 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) rec->insns, rec->exec_count); } -g_list_free (it); +g_list_free_full (it, g_free);g_mutex_unlock (&lock); } +g_hash_table_destroy (hotblocks);qemu_plugin_outs (report->str); }
Signature · 1 line
2.25.1
PATCH 2/2 plugins/hotpages: Properly freed the hash table values
In reply to Mahmoud MandourFreed the values stored in the hash table ``pages`` returned by ``g_hash_table_get_values()`` by freeing the sorted list and destroyed the hash table afterward.
--- contrib/plugins/hotpages.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
contrib/plugins/hotpages.c +2 -1
@@ -94,9 +94,10 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) rec->cpu_read, rec->reads, rec->cpu_write, rec->writes); } -g_list_free (it); +g_list_free_full (it, g_free); } +g_hash_table_destroy (pages);qemu_plugin_outs (report->str); }
Signature · 1 line
2.25.1
Alex Bennée
AppliedQuoted 3 lines · Mahmoud Mandour
A hash table made using ``g_hash_table_new`` requires manually freeing any dynamically allocated keys/values. The two patches in this series fixes this issue in hotblocks and hotpages plugins.
Queued to plugins/next, thanks.
Signature · 1 line
Alex Bennée
Quoted 7 lines · Alex Bennée
Quoted 3 lines · Mahmoud Mandour
A hash table made using ``g_hash_table_new`` requires manually freeing any dynamically allocated keys/values. The two patches in this series fixes this issue in hotblocks and hotpages plugins.
Queued to plugins/next, thanks.
Oops, dequeuing and applying v2 ;-)
Signature · 1 line
Alex Bennée