[sysprof] libsysprof: plug leak and do less strdups
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] libsysprof: plug leak and do less strdups
- Date: Tue, 18 Feb 2020 21:46:01 +0000 (UTC)
commit 93acce520f0c43306d5d58352cef20ee03f09d36
Author: Christian Hergert <chergert redhat com>
Date: Tue Feb 18 13:44:25 2020 -0800
libsysprof: plug leak and do less strdups
Small leak based on the number of PROCESS frames we see. Easy to fix and
easy to not do the g_strdup_printf() at all in those cases.
src/libsysprof/sysprof-callgraph-profile.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/src/libsysprof/sysprof-callgraph-profile.c b/src/libsysprof/sysprof-callgraph-profile.c
index b8ed45b..ce70d24 100644
--- a/src/libsysprof/sysprof-callgraph-profile.c
+++ b/src/libsysprof/sysprof-callgraph-profile.c
@@ -275,7 +275,6 @@ sysprof_callgraph_profile_generate_worker (GTask *task,
while (sysprof_capture_reader_peek_type (reader, &type))
{
const SysprofCaptureProcess *pr;
- const gchar *cmdline;
if (type != SYSPROF_CAPTURE_FRAME_PROCESS)
{
@@ -287,10 +286,13 @@ sysprof_callgraph_profile_generate_worker (GTask *task,
if (NULL == (pr = sysprof_capture_reader_read_process (reader)))
goto failure;
- cmdline = g_strdup_printf ("[%s]", pr->cmdline);
- g_hash_table_insert (cmdlines,
- GINT_TO_POINTER (pr->frame.pid),
- (gchar *)sysprof_callgraph_profile_intern_string (self, cmdline));
+ if (!g_hash_table_contains (cmdlines, GINT_TO_POINTER (pr->frame.pid)))
+ {
+ g_autofree gchar *cmdline = g_strdup_printf ("[%s]", pr->cmdline);
+ g_hash_table_insert (cmdlines,
+ GINT_TO_POINTER (pr->frame.pid),
+ (gchar *)sysprof_callgraph_profile_intern_string (self, cmdline));
+ }
}
if (g_task_return_error_if_cancelled (task))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]