mirror of
https://github.com/swaywm/sway.git
synced 2025-10-29 05:40:18 -04:00
fix list sorting
This commit is contained in:
parent
cb11364552
commit
9d50f88cef
3 changed files with 22 additions and 14 deletions
|
|
@ -50,8 +50,14 @@ void list_cat(list_t *list, list_t *source) {
|
|||
}
|
||||
}
|
||||
|
||||
// pass the pointer of the object we care about to the comparison function
|
||||
static int list_cmp(const void *l, const void *r, void *_cmp) {
|
||||
int (*cmp)(const void *, const void *) = _cmp;
|
||||
return cmp(*(void**)l, *(void**)r);
|
||||
}
|
||||
|
||||
void list_sort(list_t *list, int compare(const void *left, const void *right)) {
|
||||
qsort(list->items, list->length, sizeof(void *), compare);
|
||||
qsort_r(list->items, list->length, sizeof(void *), list_cmp, compare);
|
||||
}
|
||||
|
||||
int list_seq_find(list_t *list, int compare(const void *item, const void *data), const void *data) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue