summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/fr-process.c35
1 files changed, 9 insertions, 26 deletions
diff --git a/src/fr-process.c b/src/fr-process.c
index 892aaae..fa361e7 100644
--- a/src/fr-process.c
+++ b/src/fr-process.c
@@ -88,22 +88,16 @@ fr_command_info_new (void)
static void
-fr_command_info_free (FrCommandInfo *info)
+fr_command_info_free (gpointer data)
{
+ FrCommandInfo *info = data;
+
if (info == NULL)
return;
- if (info->args != NULL) {
- g_list_free_full (info->args, g_free);
- info->args = NULL;
- }
-
- if (info->dir != NULL) {
- g_free (info->dir);
- info->dir = NULL;
- }
-
- g_free (info);
+ g_list_free_full (info->args, g_free);
+ g_free (info->dir);
+ g_clear_pointer (&info, g_free);
}
@@ -304,7 +298,7 @@ fr_process_init (FrProcess *process)
process->term_on_stop = TRUE;
- process->priv->comm = g_ptr_array_new ();
+ process->priv->comm = g_ptr_array_new_with_free_func (fr_command_info_free);
process->priv->n_comm = -1;
process->priv->current_comm = -1;
@@ -347,9 +341,8 @@ fr_process_finalize (GObject *object)
process = FR_PROCESS (object);
fr_process_stop_priv (process, FALSE);
- fr_process_clear (process);
- g_ptr_array_free (process->priv->comm, FALSE);
+ g_ptr_array_free (process->priv->comm, TRUE);
fr_channel_data_free (&process->out);
fr_channel_data_free (&process->err);
@@ -397,9 +390,7 @@ fr_process_begin_command_at (FrProcess *process,
process->priv->current_comm = index;
old_c_info = g_ptr_array_index (process->priv->comm, index);
-
- if (old_c_info != NULL)
- fr_command_info_free (old_c_info);
+ fr_command_info_free (old_c_info);
info = fr_command_info_new ();
info->args = g_list_prepend (NULL, g_strdup (arg));
@@ -592,14 +583,6 @@ fr_process_clear (FrProcess *process)
g_return_if_fail (process != NULL);
- for (i = 0; i <= process->priv->n_comm; i++) {
- FrCommandInfo *info;
-
- info = g_ptr_array_index (process->priv->comm, i);
- fr_command_info_free (info);
- g_ptr_array_index (process->priv->comm, i) = NULL;
- }
-
for (i = 0; i <= process->priv->n_comm; i++)
g_ptr_array_remove_index_fast (process->priv->comm, 0);