| 1 | /* GLIB - Library of useful routines for C programming | 
| 2 |  * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald | 
| 3 |  * | 
| 4 |  * This library is free software; you can redistribute it and/or | 
| 5 |  * modify it under the terms of the GNU Lesser General Public | 
| 6 |  * License as published by the Free Software Foundation; either | 
| 7 |  * version 2.1 of the License, or (at your option) any later version. | 
| 8 |  * | 
| 9 |  * This library is distributed in the hope that it will be useful, | 
| 10 |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 11 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU | 
| 12 |  * Lesser General Public License for more details. | 
| 13 |  * | 
| 14 |  * You should have received a copy of the GNU Lesser General Public | 
| 15 |  * License along with this library; if not, see <http://www.gnu.org/licenses/>. | 
| 16 |  */ | 
| 17 |  | 
| 18 | /* | 
| 19 |  * Modified by the GLib Team and others 1997-2000.  See the AUTHORS | 
| 20 |  * file for a list of people on the GLib Team.  See the ChangeLog | 
| 21 |  * files for a list of changes.  These files are distributed with | 
| 22 |  * GLib at ftp://ftp.gtk.org/pub/gtk/. | 
| 23 |  */ | 
| 24 |  | 
| 25 | #ifndef __G_SLIST_H__ | 
| 26 | #define __G_SLIST_H__ | 
| 27 |  | 
| 28 | #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) | 
| 29 | #error "Only <glib.h> can be included directly." | 
| 30 | #endif | 
| 31 |  | 
| 32 | #include <glib/gmem.h> | 
| 33 | #include <glib/gnode.h> | 
| 34 |  | 
| 35 | G_BEGIN_DECLS | 
| 36 |  | 
| 37 | typedef struct _GSList GSList; | 
| 38 |  | 
| 39 | struct _GSList | 
| 40 | { | 
| 41 |   gpointer data; | 
| 42 |   GSList *next; | 
| 43 | }; | 
| 44 |  | 
| 45 | /* Singly linked lists | 
| 46 |  */ | 
| 47 | GLIB_AVAILABLE_IN_ALL | 
| 48 | GSList*  g_slist_alloc                   (void) G_GNUC_WARN_UNUSED_RESULT; | 
| 49 | GLIB_AVAILABLE_IN_ALL | 
| 50 | void     g_slist_free                    (GSList           *list); | 
| 51 | GLIB_AVAILABLE_IN_ALL | 
| 52 | void     g_slist_free_1                  (GSList           *list); | 
| 53 | #define	 g_slist_free1		         g_slist_free_1 | 
| 54 | GLIB_AVAILABLE_IN_ALL | 
| 55 | void     g_slist_free_full               (GSList           *list, | 
| 56 | 					  GDestroyNotify    free_func); | 
| 57 | GLIB_AVAILABLE_IN_ALL | 
| 58 | GSList*  g_slist_append                  (GSList           *list, | 
| 59 | 					  gpointer          data) G_GNUC_WARN_UNUSED_RESULT; | 
| 60 | GLIB_AVAILABLE_IN_ALL | 
| 61 | GSList*  g_slist_prepend                 (GSList           *list, | 
| 62 | 					  gpointer          data) G_GNUC_WARN_UNUSED_RESULT; | 
| 63 | GLIB_AVAILABLE_IN_ALL | 
| 64 | GSList*  g_slist_insert                  (GSList           *list, | 
| 65 | 					  gpointer          data, | 
| 66 | 					  gint              position) G_GNUC_WARN_UNUSED_RESULT; | 
| 67 | GLIB_AVAILABLE_IN_ALL | 
| 68 | GSList*  g_slist_insert_sorted           (GSList           *list, | 
| 69 | 					  gpointer          data, | 
| 70 | 					  GCompareFunc      func) G_GNUC_WARN_UNUSED_RESULT; | 
| 71 | GLIB_AVAILABLE_IN_ALL | 
| 72 | GSList*  g_slist_insert_sorted_with_data (GSList           *list, | 
| 73 | 					  gpointer          data, | 
| 74 | 					  GCompareDataFunc  func, | 
| 75 | 					  gpointer          user_data) G_GNUC_WARN_UNUSED_RESULT; | 
| 76 | GLIB_AVAILABLE_IN_ALL | 
| 77 | GSList*  g_slist_insert_before           (GSList           *slist, | 
| 78 | 					  GSList           *sibling, | 
| 79 | 					  gpointer          data) G_GNUC_WARN_UNUSED_RESULT; | 
| 80 | GLIB_AVAILABLE_IN_ALL | 
| 81 | GSList*  g_slist_concat                  (GSList           *list1, | 
| 82 | 					  GSList           *list2) G_GNUC_WARN_UNUSED_RESULT; | 
| 83 | GLIB_AVAILABLE_IN_ALL | 
| 84 | GSList*  g_slist_remove                  (GSList           *list, | 
| 85 | 					  gconstpointer     data) G_GNUC_WARN_UNUSED_RESULT; | 
| 86 | GLIB_AVAILABLE_IN_ALL | 
| 87 | GSList*  g_slist_remove_all              (GSList           *list, | 
| 88 | 					  gconstpointer     data) G_GNUC_WARN_UNUSED_RESULT; | 
| 89 | GLIB_AVAILABLE_IN_ALL | 
| 90 | GSList*  g_slist_remove_link             (GSList           *list, | 
| 91 | 					  GSList           *link_) G_GNUC_WARN_UNUSED_RESULT; | 
| 92 | GLIB_AVAILABLE_IN_ALL | 
| 93 | GSList*  g_slist_delete_link             (GSList           *list, | 
| 94 | 					  GSList           *link_) G_GNUC_WARN_UNUSED_RESULT; | 
| 95 | GLIB_AVAILABLE_IN_ALL | 
| 96 | GSList*  g_slist_reverse                 (GSList           *list) G_GNUC_WARN_UNUSED_RESULT; | 
| 97 | GLIB_AVAILABLE_IN_ALL | 
| 98 | GSList*  g_slist_copy                    (GSList           *list) G_GNUC_WARN_UNUSED_RESULT; | 
| 99 |  | 
| 100 | GLIB_AVAILABLE_IN_2_34 | 
| 101 | GSList*  g_slist_copy_deep               (GSList            *list, | 
| 102 | 					  GCopyFunc         func, | 
| 103 | 					  gpointer          user_data) G_GNUC_WARN_UNUSED_RESULT; | 
| 104 | GLIB_AVAILABLE_IN_ALL | 
| 105 | GSList*  g_slist_nth                     (GSList           *list, | 
| 106 | 					  guint             n); | 
| 107 | GLIB_AVAILABLE_IN_ALL | 
| 108 | GSList*  g_slist_find                    (GSList           *list, | 
| 109 | 					  gconstpointer     data); | 
| 110 | GLIB_AVAILABLE_IN_ALL | 
| 111 | GSList*  g_slist_find_custom             (GSList           *list, | 
| 112 | 					  gconstpointer     data, | 
| 113 | 					  GCompareFunc      func); | 
| 114 | GLIB_AVAILABLE_IN_ALL | 
| 115 | gint     g_slist_position                (GSList           *list, | 
| 116 | 					  GSList           *llink); | 
| 117 | GLIB_AVAILABLE_IN_ALL | 
| 118 | gint     g_slist_index                   (GSList           *list, | 
| 119 | 					  gconstpointer     data); | 
| 120 | GLIB_AVAILABLE_IN_ALL | 
| 121 | GSList*  g_slist_last                    (GSList           *list); | 
| 122 | GLIB_AVAILABLE_IN_ALL | 
| 123 | guint    g_slist_length                  (GSList           *list); | 
| 124 | GLIB_AVAILABLE_IN_ALL | 
| 125 | void     g_slist_foreach                 (GSList           *list, | 
| 126 | 					  GFunc             func, | 
| 127 | 					  gpointer          user_data); | 
| 128 | GLIB_AVAILABLE_IN_ALL | 
| 129 | GSList*  g_slist_sort                    (GSList           *list, | 
| 130 | 					  GCompareFunc      compare_func) G_GNUC_WARN_UNUSED_RESULT; | 
| 131 | GLIB_AVAILABLE_IN_ALL | 
| 132 | GSList*  g_slist_sort_with_data          (GSList           *list, | 
| 133 | 					  GCompareDataFunc  compare_func, | 
| 134 | 					  gpointer          user_data) G_GNUC_WARN_UNUSED_RESULT; | 
| 135 | GLIB_AVAILABLE_IN_ALL | 
| 136 | gpointer g_slist_nth_data                (GSList           *list, | 
| 137 | 					  guint             n); | 
| 138 |  | 
| 139 | GLIB_AVAILABLE_IN_2_64 | 
| 140 | void     g_clear_slist                   (GSList          **slist_ptr, | 
| 141 |                                           GDestroyNotify    destroy); | 
| 142 |  | 
| 143 | #define  g_clear_slist(slist_ptr, destroy)       \ | 
| 144 |   G_STMT_START {                                 \ | 
| 145 |     GSList *_slist;                              \ | 
| 146 |                                                  \ | 
| 147 |     _slist = *(slist_ptr);                       \ | 
| 148 |     if (_slist)                                  \ | 
| 149 |       {                                          \ | 
| 150 |         *slist_ptr = NULL;                       \ | 
| 151 |                                                  \ | 
| 152 |         if ((destroy) != NULL)                   \ | 
| 153 |           g_slist_free_full (_slist, (destroy)); \ | 
| 154 |         else                                     \ | 
| 155 |           g_slist_free (_slist);                 \ | 
| 156 |       }                                          \ | 
| 157 |   } G_STMT_END                                   \ | 
| 158 |   GLIB_AVAILABLE_MACRO_IN_2_64 | 
| 159 |  | 
| 160 | #define  g_slist_next(slist)	         ((slist) ? (((GSList *)(slist))->next) : NULL) | 
| 161 |  | 
| 162 | G_END_DECLS | 
| 163 |  | 
| 164 | #endif /* __G_SLIST_H__ */ | 
| 165 |  |