At the same time, add a refcount and public ref/unref methods.
This makes it usable from introspectable.
https://bugzilla.gnome.org/show_bug.cgi?id=690084
g_markup_parse_context_parse
g_markup_parse_context_push
g_markup_parse_context_pop
+g_markup_parse_context_ref
+g_markup_parse_context_unref
<SUBSECTION>
GMarkupCollectType
g_markup_collect_attributes
G_TYPE_KEY_FILE
G_TYPE_MAIN_CONTEXT
G_TYPE_MAIN_LOOP
+G_TYPE_MARKUP_PARSE_CONTEXT
G_TYPE_SOURCE
G_TYPE_POLLFD
G_TYPE_THREAD
g_markup_parse_context_parse
g_markup_parse_context_push
g_markup_parse_context_pop
+g_markup_parse_context_ref
+g_markup_parse_context_unref
g_markup_printf_escaped
g_markup_vprintf_escaped
g_markup_collect_attributes
#include "gmarkup.h"
+#include "gatomic.h"
#include "gslice.h"
#include "galloca.h"
#include "gstrfuncs.h"
{
const GMarkupParser *parser;
+ volatile gint ref_count;
+
GMarkupParseFlags flags;
gint line_number;
context = g_new (GMarkupParseContext, 1);
+ context->ref_count = 1;
context->parser = parser;
context->flags = flags;
context->user_data = user_data;
return context;
}
+/**
+ * g_markup_parse_context_ref:
+ * @context: a #GMarkupParseContext
+ *
+ * Increases the reference count of @context.
+ *
+ * Returns: the same @context
+ *
+ * Since: 2.36
+ **/
+GMarkupParseContext *
+g_markup_parse_context_ref (GMarkupParseContext *context)
+{
+ g_return_val_if_fail (context != NULL, NULL);
+ g_return_val_if_fail (context->ref_count > 0, NULL);
+
+ g_atomic_int_inc (&context->ref_count);
+
+ return context;
+}
+
+/**
+ * g_markup_parse_context_unref:
+ * @context: a #GMarkupParseContext
+ *
+ * Decreases the reference count of @context. When its reference count
+ * drops to 0, it is freed.
+ *
+ * Since: 2.36
+ **/
+void
+g_markup_parse_context_unref (GMarkupParseContext *context)
+{
+ g_return_if_fail (context != NULL);
+ g_return_if_fail (context->ref_count > 0);
+
+ if (g_atomic_int_dec_and_test (&context->ref_count))
+ g_markup_parse_context_free (context);
+}
+
static void
string_full_free (gpointer ptr)
{
GMarkupParseFlags flags,
gpointer user_data,
GDestroyNotify user_data_dnotify);
+GLIB_AVAILABLE_IN_2_36
+GMarkupParseContext *g_markup_parse_context_ref (GMarkupParseContext *context);
+GLIB_AVAILABLE_IN_2_36
+void g_markup_parse_context_unref (GMarkupParseContext *context);
void g_markup_parse_context_free (GMarkupParseContext *context);
gboolean g_markup_parse_context_parse (GMarkupParseContext *context,
const gchar *text,
G_DEFINE_BOXED_TYPE (GMainContext, g_main_context, g_main_context_ref, g_main_context_unref)
G_DEFINE_BOXED_TYPE (GSource, g_source, g_source_ref, g_source_unref)
G_DEFINE_BOXED_TYPE (GPollFD, g_pollfd, pollfd_copy, g_free)
+G_DEFINE_BOXED_TYPE (GMarkupParseContext, g_markup_parse_context, g_markup_parse_context_ref, g_markup_parse_context_unref)
G_DEFINE_BOXED_TYPE (GThread, g_thread, g_thread_ref, g_thread_unref)
G_DEFINE_BOXED_TYPE (GChecksum, g_checksum, g_checksum_copy, g_checksum_free)
#define G_TYPE_POLLFD (g_pollfd_get_type ())
/**
+ * G_TYPE_MARKUP_PARSE_CONTEXT:
+ *
+ * The #GType for a boxed type holding a #GMarkupParseContext.
+ *
+ * Since: 2.36
+ */
+#define G_TYPE_MARKUP_PARSE_CONTEXT (g_markup_parse_context_get_type ())
+
+/**
* G_TYPE_KEY_FILE:
*
* The #GType for a boxed type holding a #GKeyFile.
GType g_thread_get_type (void) G_GNUC_CONST;
GLIB_AVAILABLE_IN_2_36
GType g_checksum_get_type (void) G_GNUC_CONST;
+GLIB_AVAILABLE_IN_2_36
+GType g_markup_parse_context_get_type (void) G_GNUC_CONST;
GLIB_DEPRECATED_FOR('G_TYPE_VARIANT')
GType g_variant_get_gtype (void) G_GNUC_CONST;
g_key_file_get_type
g_main_loop_get_type
g_main_context_get_type
+g_markup_parse_context_get_type
g_source_get_type
g_pollfd_get_type
g_closure_get_type