Commit 98f60935 authored by Christian Hergert's avatar Christian Hergert

xml-pack: fix some leaks and const miss-use

parent 72087a0a
......@@ -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 *
......
......@@ -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 *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment