* [PATCH 0/2] plugins: Freeing allocated values in hash tables.
@ 2021-04-21 14:09 Mahmoud Mandour
2021-04-21 14:09 ` [PATCH 1/2] plugins/hotblocks: Properly freed the hash table values Mahmoud Mandour
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Mahmoud Mandour @ 2021-04-21 14:09 UTC (permalink / raw)
To: qemu-devel; +Cc: 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.
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(-)
--
2.25.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] plugins/hotblocks: Properly freed the hash table values
2021-04-21 14:09 [PATCH 0/2] plugins: Freeing allocated values in hash tables Mahmoud Mandour
@ 2021-04-21 14:09 ` Mahmoud Mandour
2021-04-21 14:09 ` [PATCH 2/2] plugins/hotpages: " Mahmoud Mandour
2021-04-26 16:53 ` [PATCH 0/2] plugins: Freeing allocated values in hash tables Alex Bennée
2 siblings, 0 replies; 5+ messages in thread
From: Mahmoud Mandour @ 2021-04-21 14:09 UTC (permalink / raw)
To: qemu-devel; +Cc: Mahmoud Mandour, Alex Bennée
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.
Signed-off-by: Mahmoud Mandour <ma.mandourr@gmail.com>
---
contrib/plugins/hotblocks.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/contrib/plugins/hotblocks.c b/contrib/plugins/hotblocks.c
index 4b08340143..64692c0670 100644
--- a/contrib/plugins/hotblocks.c
+++ b/contrib/plugins/hotblocks.c
@@ -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);
}
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] plugins/hotpages: Properly freed the hash table values
2021-04-21 14:09 [PATCH 0/2] plugins: Freeing allocated values in hash tables Mahmoud Mandour
2021-04-21 14:09 ` [PATCH 1/2] plugins/hotblocks: Properly freed the hash table values Mahmoud Mandour
@ 2021-04-21 14:09 ` Mahmoud Mandour
2021-04-26 16:53 ` [PATCH 0/2] plugins: Freeing allocated values in hash tables Alex Bennée
2 siblings, 0 replies; 5+ messages in thread
From: Mahmoud Mandour @ 2021-04-21 14:09 UTC (permalink / raw)
To: qemu-devel; +Cc: Mahmoud Mandour, Alex Bennée
Freed 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.
Signed-off-by: Mahmoud Mandour <ma.mandourr@gmail.com>
---
contrib/plugins/hotpages.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/contrib/plugins/hotpages.c b/contrib/plugins/hotpages.c
index bf53267532..2094ebd15f 100644
--- a/contrib/plugins/hotpages.c
+++ b/contrib/plugins/hotpages.c
@@ -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);
}
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] plugins: Freeing allocated values in hash tables.
2021-04-21 14:09 [PATCH 0/2] plugins: Freeing allocated values in hash tables Mahmoud Mandour
2021-04-21 14:09 ` [PATCH 1/2] plugins/hotblocks: Properly freed the hash table values Mahmoud Mandour
2021-04-21 14:09 ` [PATCH 2/2] plugins/hotpages: " Mahmoud Mandour
@ 2021-04-26 16:53 ` Alex Bennée
2021-04-26 16:54 ` Alex Bennée
2 siblings, 1 reply; 5+ messages in thread
From: Alex Bennée @ 2021-04-26 16:53 UTC (permalink / raw)
To: Mahmoud Mandour; +Cc: qemu-devel
Mahmoud Mandour <ma.mandourr@gmail.com> writes:
> 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.
--
Alex Bennée
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] plugins: Freeing allocated values in hash tables.
2021-04-26 16:53 ` [PATCH 0/2] plugins: Freeing allocated values in hash tables Alex Bennée
@ 2021-04-26 16:54 ` Alex Bennée
0 siblings, 0 replies; 5+ messages in thread
From: Alex Bennée @ 2021-04-26 16:54 UTC (permalink / raw)
To: Mahmoud Mandour; +Cc: qemu-devel
Alex Bennée <alex.bennee@linaro.org> writes:
> Mahmoud Mandour <ma.mandourr@gmail.com> writes:
>
>> 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 ;-)
--
Alex Bennée
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-04-26 16:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-21 14:09 [PATCH 0/2] plugins: Freeing allocated values in hash tables Mahmoud Mandour
2021-04-21 14:09 ` [PATCH 1/2] plugins/hotblocks: Properly freed the hash table values Mahmoud Mandour
2021-04-21 14:09 ` [PATCH 2/2] plugins/hotpages: " Mahmoud Mandour
2021-04-26 16:53 ` [PATCH 0/2] plugins: Freeing allocated values in hash tables Alex Bennée
2021-04-26 16:54 ` Alex Bennée
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).