diff options
Diffstat (limited to 'src/ref.c')
| -rw-r--r-- | src/ref.c | 33 |
1 files changed, 17 insertions, 16 deletions
@@ -27,37 +27,37 @@ refs_free(struct list *list) list_free(list, ref_free, LINK_OFFSET(struct ref, link)); } -static struct link * -refs_ffind(struct list *list, void *data) +int +refs_index(struct list *list, void *data) { struct link *iter; struct ref *ref; + int index; + index = 0; for (LIST_ITER(list, iter)) { - ref = UPCAST(iter, struct ref); + ref = UPCAST(iter, struct ref, link); if (ref->data == data) - return iter; + return index; + index++; } - return NULL; + return -1; } -int -refs_index(struct list *list, void *data) +struct link * +refs_find(struct list *list, void *data) { struct link *iter; struct ref *ref; - int index; - index = 0; for (LIST_ITER(list, iter)) { - ref = UPCAST(iter, struct ref); + ref = UPCAST(iter, struct ref, link); if (ref->data == data) - return index; - index++; + return iter; } - return -1; + return NULL; } int @@ -65,7 +65,8 @@ refs_incl(struct list *list, void *data) { struct link *ref; - ref = refs_ffind(list, data); + ref = refs_find(list, data); + return ref != NULL; } @@ -75,10 +76,10 @@ refs_rm(struct list *list, void *data) struct link *ref; struct ref *dataref; - ref = refs_ffind(list, data); + ref = refs_find(list, data); if (!ref) return; - dataref = UPCAST(ref, struct ref); + dataref = UPCAST(ref, struct ref, link); link_pop(ref); free(dataref); } |
