mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-12-02 16:44:18 +08:00
Add g_slist_nth, g_slist_nth_data, g_slist_last and g_slist_position functions to eglib.
This commit is contained in:
parent
5c3cff06eb
commit
e11b4cced0
@ -1127,6 +1127,43 @@ void g_slist_free(GSList *list)
|
||||
}
|
||||
}
|
||||
|
||||
GSList *g_slist_nth(GSList *list, guint n)
|
||||
{
|
||||
while (n-- > 0 && list)
|
||||
list = list->next;
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
gpointer g_slist_nth_data(GSList *list, guint n)
|
||||
{
|
||||
while (n-- > 0 && list)
|
||||
list = list->next;
|
||||
|
||||
return list ? list->data : NULL;
|
||||
}
|
||||
|
||||
gint g_slist_position(GSList *list, GSList *link)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; list; list = list->next, i++) {
|
||||
if (list == link)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
GSList* g_slist_last(GSList *list)
|
||||
{
|
||||
if (list)
|
||||
while (list->next)
|
||||
list = list->next;
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/* Memory allocation functions */
|
||||
|
||||
gpointer g_malloc(gulong n_bytes)
|
||||
|
@ -192,6 +192,11 @@ int g_slist_length(GSList *list);
|
||||
void g_slist_foreach(GSList *list, GFunc func, void *user_data);
|
||||
void g_slist_free(GSList *list);
|
||||
|
||||
GSList *g_slist_nth(GSList *list, guint n);
|
||||
gpointer g_slist_nth_data(GSList *list, guint n);
|
||||
int g_slist_position(GSList *list, GSList *link);
|
||||
GSList* g_slist_last(GSList *list);
|
||||
|
||||
/* End GSList declarations */
|
||||
|
||||
/* Memory allocation related */
|
||||
|
Loading…
Reference in New Issue
Block a user