[gnome-builder] xml-pack: fix some leaks and const miss-use
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] xml-pack: fix some leaks and const miss-use
- Date: Tue, 19 Jun 2018 00:25:40 +0000 (UTC)
commit 98f60935e144885470885acf0a9c7d8071fa8ee0
Author: Christian Hergert <chergert redhat com>
Date: Mon Jun 18 17:23:25 2018 -0700
xml-pack: fix some leaks and const miss-use
src/plugins/xml-pack/ide-xml-completion-provider.c | 17 ++++++++++-------
src/plugins/xml-pack/ide-xml-completion-values.c | 22 +++++++++++-----------
2 files changed, 21 insertions(+), 18 deletions(-)
---
diff --git a/src/plugins/xml-pack/ide-xml-completion-provider.c
b/src/plugins/xml-pack/ide-xml-completion-provider.c
index 909a91222..09c61246e 100644
--- a/src/plugins/xml-pack/ide-xml-completion-provider.c
+++ b/src/plugins/xml-pack/ide-xml-completion-provider.c
@@ -48,7 +48,7 @@ typedef struct
IdeXmlRngDefine *define;
GPtrArray *children;
GPtrArray *items;
- const gchar *prefix;
+ gchar *prefix;
gint child_cursor;
gint define_cursor;
@@ -163,7 +163,7 @@ state_stack_pop (MatchingState *state)
return FALSE;
item = &g_array_index (state->stack, StateStackItem, len - 1);
- g_clear_pointer (&state->children, g_ptr_array_unref);
+ dzl_clear_pointer (&state->children, g_ptr_array_unref);
state->children = item->children;
state->candidate_node = item->candidate_node;
@@ -384,8 +384,9 @@ completion_item_new (const gchar *label,
static void
completion_item_free (CompletionItem *item)
{
- g_clear_pointer (&item->label, g_free);
- g_clear_pointer (&item->define, ide_xml_rng_define_unref);
+ dzl_clear_pointer (&item->label, g_free);
+ dzl_clear_pointer (&item->define, ide_xml_rng_define_unref);
+ g_slice_free (CompletionItem, item);
}
static MatchingState *
@@ -451,9 +452,11 @@ matching_state_free (MatchingState *state)
g_clear_object (&state->parent_node);
g_clear_object (&state->candidate_node);
- g_clear_pointer (&state->prefix, g_free);
- g_clear_pointer (&state->children, g_ptr_array_unref);
- g_clear_pointer (&state->stack, g_array_unref);
+ dzl_clear_pointer (&state->prefix, g_free);
+ dzl_clear_pointer (&state->children, g_ptr_array_unref);
+ dzl_clear_pointer (&state->stack, g_array_unref);
+
+ g_slice_free (MatchingState, state);
}
static MatchingState *
diff --git a/src/plugins/xml-pack/ide-xml-completion-values.c
b/src/plugins/xml-pack/ide-xml-completion-values.c
index 0bb8c39b2..d7a0831cf 100644
--- a/src/plugins/xml-pack/ide-xml-completion-values.c
+++ b/src/plugins/xml-pack/ide-xml-completion-values.c
@@ -19,14 +19,13 @@
#include "ide-xml-completion-values.h"
#include "ide-xml-position.h"
-typedef struct _MatchingState
+typedef struct
{
- IdeXmlRngDefine *define;
- GPtrArray *match_values;
- const gchar *values;
- const gchar *prefix;
+ IdeXmlRngDefine *define;
+ gchar *values;
+ gchar *prefix;
- guint is_initial_state : 1;
+ guint is_initial_state : 1;
} MatchingState;
static GPtrArray * process_matching_state (MatchingState *state,
@@ -50,7 +49,7 @@ value_match_item_free (gpointer data)
{
ValueMatchItem *item = (ValueMatchItem *)data;
- g_clear_pointer (&item->name, g_free);
+ dzl_clear_pointer (&item->name, g_free);
g_slice_free (ValueMatchItem, item);
}
@@ -95,8 +94,8 @@ matching_state_new (IdeXmlRngDefine *define,
state = g_slice_new0 (MatchingState);
state->define = define;
- state->values = (values != NULL) ? g_strdup (values) : NULL;
- state->prefix = (prefix != NULL) ? g_strdup (prefix) : NULL;
+ state->values = g_strdup (values);
+ state->prefix = g_strdup (prefix);
state->is_initial_state = FALSE;
@@ -106,8 +105,9 @@ matching_state_new (IdeXmlRngDefine *define,
static void
matching_state_free (MatchingState *state)
{
- g_clear_pointer (&state->values, g_free);
- g_clear_pointer (&state->prefix, g_free);
+ dzl_clear_pointer (&state->values, g_free);
+ dzl_clear_pointer (&state->prefix, g_free);
+ g_slice_free (MatchingState, state);
}
static GPtrArray *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]