r15361 - gnucash/branches/sx-cleanup/src/core-utils - Add utility code to split a glist into two pieces at a cutpoint.
Josh Sled
jsled at cvs.gnucash.org
Sat Jan 13 17:12:30 EST 2007
Author: jsled
Date: 2007-01-13 17:12:29 -0500 (Sat, 13 Jan 2007)
New Revision: 15361
Trac: http://svn.gnucash.org/trac/changeset/15361
Modified:
gnucash/branches/sx-cleanup/src/core-utils/gnc-glib-utils.c
gnucash/branches/sx-cleanup/src/core-utils/gnc-glib-utils.h
Log:
Add utility code to split a glist into two pieces at a cutpoint.
Modified: gnucash/branches/sx-cleanup/src/core-utils/gnc-glib-utils.c
===================================================================
--- gnucash/branches/sx-cleanup/src/core-utils/gnc-glib-utils.c 2007-01-13 19:58:39 UTC (rev 15360)
+++ gnucash/branches/sx-cleanup/src/core-utils/gnc-glib-utils.c 2007-01-13 22:12:29 UTC (rev 15361)
@@ -76,3 +76,17 @@
}
return rtn;
}
+
+void
+gnc_g_list_cut(GList **list, GList *cut_point)
+{
+ if (list == NULL || *list == NULL)
+ return;
+
+ // if it's the first element.
+ if (cut_point->prev == NULL)
+ *list = NULL;
+
+ cut_point->prev->next = NULL;
+ cut_point->prev = NULL;
+}
Modified: gnucash/branches/sx-cleanup/src/core-utils/gnc-glib-utils.h
===================================================================
--- gnucash/branches/sx-cleanup/src/core-utils/gnc-glib-utils.h 2007-01-13 19:58:39 UTC (rev 15360)
+++ gnucash/branches/sx-cleanup/src/core-utils/gnc-glib-utils.h 2007-01-13 22:12:29 UTC (rev 15361)
@@ -82,6 +82,13 @@
**/
GList* gnc_g_list_map(GList* list, GncGMapFunc fn, gpointer user_data);
+/**
+ * Cut a GList into two parts; the {@param cut_point} is the beginning of the
+ * new list; {@param list} may need to be modified, but will be the list
+ * before the {@param cut_point}.
+ **/
+void gnc_g_list_cut(GList **list, GList *cut_point);
+
/** @} */
#endif /* GNC_GLIB_UTILS_H */
More information about the gnucash-changes
mailing list