Add fluid_list function to find index of data in list

Will be used in the defsfont dump utility.
This commit is contained in:
Marcus Weseloh 2021-03-22 00:54:24 +01:00
parent 8a39c5aea4
commit 1b61e1fbd3
2 changed files with 17 additions and 0 deletions

View file

@ -319,3 +319,19 @@ fluid_list_str_compare_func(void *a, void *b)
return 1;
}
int fluid_list_idx(fluid_list_t *list, void *data)
{
int i = 0;
while(list)
{
if (list->data == data)
{
return i;
}
list = list->next;
}
return -1;
}

View file

@ -52,6 +52,7 @@ fluid_list_t *fluid_list_remove_link(fluid_list_t *list, fluid_list_t *llink);
fluid_list_t *fluid_list_nth(fluid_list_t *list, int n);
fluid_list_t *fluid_list_last(fluid_list_t *list);
fluid_list_t *fluid_list_insert_at(fluid_list_t *list, int n, void *data);
int fluid_list_idx(fluid_list_t *list, void *data);
int fluid_list_size(fluid_list_t *list);
#define fluid_list_next(slist) ((slist) ? (((fluid_list_t *)(slist))->next) : NULL)