[evolution-kolab] libekolabutil: added micro-implementation of a GList with constant data
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab] libekolabutil: added micro-implementation of a GList with constant data
- Date: Mon, 30 Jul 2012 14:48:35 +0000 (UTC)
commit 594d33e9719534b1c8b309787deee86e56930dc2
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Mon Jul 30 16:23:00 2012 +0200
libekolabutil: added micro-implementation of a GList with constant data
src/libekolabutil/kolab-util-glib.c | 54 +++++++++++++++++++++++++++++++++++
src/libekolabutil/kolab-util-glib.h | 11 +++++++
2 files changed, 65 insertions(+), 0 deletions(-)
---
diff --git a/src/libekolabutil/kolab-util-glib.c b/src/libekolabutil/kolab-util-glib.c
index f21a41e..a43b04a 100644
--- a/src/libekolabutil/kolab-util-glib.c
+++ b/src/libekolabutil/kolab-util-glib.c
@@ -161,4 +161,58 @@ kolab_util_glib_string_gcompare (gconstpointer a,
return g_strcmp0 (str_a, str_b);
}
+void
+kolab_util_glib_gconstlist_free (KolabGConstList *list)
+{
+ KolabGConstList *anchor = NULL;
+ KolabGConstList *ptr = NULL;
+
+ if (list == NULL)
+ return;
+
+ anchor = list;
+ ptr = list->next;
+
+ while (ptr != NULL) {
+ g_free (anchor);
+ anchor = ptr;
+ ptr = anchor->next;
+ }
+ g_free (anchor);
+}
+
+KolabGConstList*
+kolab_util_glib_gconstlist_prepend (KolabGConstList *list, gconstpointer data)
+{
+ KolabGConstList *elem = g_new0 (KolabGConstList, 1);
+
+ elem->const_data = data;
+ elem->next = list;
+ if (list != NULL)
+ list->prev = elem;
+
+ return elem;
+}
+
+KolabGConstList*
+kolab_util_glib_gconstlist_append (KolabGConstList *list, gconstpointer data)
+{
+ KolabGConstList *elem = g_new0 (KolabGConstList, 1);
+ KolabGConstList *ptr = NULL;
+
+ elem->const_data = data;
+
+ if (list == NULL)
+ return elem;
+
+ ptr = list;
+ while (ptr->next != NULL)
+ ptr = ptr->next;
+
+ ptr->next = elem;
+ elem->prev = ptr;
+
+ return list;
+}
+
/*----------------------------------------------------------------------------*/
diff --git a/src/libekolabutil/kolab-util-glib.h b/src/libekolabutil/kolab-util-glib.h
index 2133a44..543d9da 100644
--- a/src/libekolabutil/kolab-util-glib.h
+++ b/src/libekolabutil/kolab-util-glib.h
@@ -50,6 +50,17 @@ void kolab_util_glib_glist_gdestroy (gpointer data);
gint kolab_util_glib_string_gcompare (gconstpointer a, gconstpointer b);
+typedef struct _KolabGConstList KolabGConstList;
+struct _KolabGConstList {
+ gconstpointer const_data;
+ KolabGConstList *next;
+ KolabGConstList *prev;
+};
+
+void kolab_util_glib_gconstlist_free (KolabGConstList *list);
+KolabGConstList* kolab_util_glib_gconstlist_prepend (KolabGConstList *list, gconstpointer data);
+KolabGConstList* kolab_util_glib_gconstlist_append (KolabGConstList *list, gconstpointer data);
+
/*----------------------------------------------------------------------------*/
#endif /* _KOLAB_UTIL_GLIB_H_ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]