add feature for sorting list.

This commit is contained in:
Gatsby Van
2023-12-23 17:01:39 +08:00
parent 4b79a1436a
commit d746215628
2 changed files with 5 additions and 5 deletions
+4 -3
View File
@@ -12,6 +12,7 @@
// Copyright (c) 2010 TJ Holowaychuk <[email protected]>
//
#include <stdint.h>
#include "list.h"
/*
@@ -41,7 +42,7 @@ list_new(void) {
self->head = NULL;
self->tail = NULL;
self->free = NULL;
self->match = NULL;
self->compare = NULL;
self->len = 0;
return self;
}
@@ -181,8 +182,8 @@ list_find(list_t *self, void *val) {
list_node_t *node;
while ((node = list_iterator_next(it))) {
if (self->match) {
if (self->match(val, node->val)) {
if (self->compare) {
if (self->compare(val, node->val) == 0) {
list_iterator_destroy(it);
return node;
}