[gnome-builder/wip/highlight] highlight: use boxed type, increment ref count



commit 5061f3200c2ace3ff42f03530a0a2537bca76827
Author: Christian Hergert <christian hergert me>
Date:   Thu Mar 26 13:11:30 2015 -0700

    highlight: use boxed type, increment ref count

 libide/ide-highlight-index.c |    5 +++++
 libide/ide-highlight-index.h |   21 +++++++++++++--------
 2 files changed, 18 insertions(+), 8 deletions(-)
---
diff --git a/libide/ide-highlight-index.c b/libide/ide-highlight-index.c
index 03e79d6..ff80531 100644
--- a/libide/ide-highlight-index.c
+++ b/libide/ide-highlight-index.c
@@ -20,6 +20,9 @@
 
 #include "ide-highlight-index.h"
 
+G_DEFINE_BOXED_TYPE (IdeHighlightIndex, ide_highlight_index,
+                     ide_highlight_index_ref, ide_highlight_index_unref)
+
 struct _IdeHighlightIndex
 {
   volatile gint  ref_count;
@@ -78,6 +81,8 @@ ide_highlight_index_ref (IdeHighlightIndex *self)
   g_assert (self);
   g_assert_cmpint (self->ref_count, >, 0);
 
+  g_atomic_int_inc (&self->ref_count);
+
   return self;
 }
 
diff --git a/libide/ide-highlight-index.h b/libide/ide-highlight-index.h
index 6a0887c..c36d173 100644
--- a/libide/ide-highlight-index.h
+++ b/libide/ide-highlight-index.h
@@ -23,16 +23,21 @@
 
 G_BEGIN_DECLS
 
+#define IDE_TYPE_HIGHLIGHT_INDEX (ide_highlight_index_get_type())
+
 typedef struct _IdeHighlightIndex IdeHighlightIndex;
 
-IdeHighlightIndex *ide_highlight_index_new    (void);
-IdeHighlightIndex *ide_highlight_index_ref    (IdeHighlightIndex *self);
-void               ide_highlight_index_unref  (IdeHighlightIndex *self);
-void               ide_highlight_index_insert (IdeHighlightIndex *self,
-                                               const gchar       *word,
-                                               IdeHighlightKind   kind);
-IdeHighlightKind   ide_highlight_index_lookup (IdeHighlightIndex *self,
-                                               const gchar       *word);
+GType              ide_highlight_index_get_type (void);
+IdeHighlightIndex *ide_highlight_index_new      (void);
+IdeHighlightIndex *ide_highlight_index_ref      (IdeHighlightIndex *self);
+void               ide_highlight_index_unref    (IdeHighlightIndex *self);
+void               ide_highlight_index_insert   (IdeHighlightIndex *self,
+                                                 const gchar       *word,
+                                                 IdeHighlightKind   kind);
+IdeHighlightKind   ide_highlight_index_lookup   (IdeHighlightIndex *self,
+                                                 const gchar       *word);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (IdeHighlightIndex, ide_highlight_index_unref)
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]