diff --git a/src/donations.c b/src/donations.c index 0b1413a5f..4dee36444 100644 --- a/src/donations.c +++ b/src/donations.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include @@ -15,7 +15,7 @@ typedef struct transfer { int amount; } transfer; -static quicklist *transfers = 0; +static selist *transfers = 0; int cmp_transfer(const void *v1, const void *v2) { const transfer *t1 = (const transfer *)v1; @@ -35,22 +35,22 @@ int cmp_transfer(const void *v1, const void *v2) { void add_donation(faction * f1, faction * f2, int amount, region * r) { transfer tr, *tf; - quicklist *ql = transfers; + selist *ql = transfers; int qi = 0; tr.r = r; tr.f1 = f1; tr.f2 = f2; tr.amount = amount; - if (ql_set_find_ex(&ql, &qi, &tr, cmp_transfer)) { - tf = (transfer *)ql_get(ql, qi); + if (selist_set_find(&ql, &qi, &tr, cmp_transfer)) { + tf = (transfer *)selist_get(ql, qi); tf->amount += amount; } else { tf = malloc(sizeof(transfer)); memcpy(tf, &tr, sizeof(transfer)); } - ql_set_insert_ex(&transfers, tf, cmp_transfer); + selist_set_insert(&transfers, tf, cmp_transfer); } void free_donations(void) { diff --git a/src/quicklist.c b/src/quicklist.c index 2b760019c..6fb567a64 100644 --- a/src/quicklist.c +++ b/src/quicklist.c @@ -1,6 +1,51 @@ #include "quicklist.h" #include +void ql_push(struct quicklist **qlp, void *el) +{ + selist_push(qlp, el); +} + +int ql_length(const struct quicklist *ql) +{ + return selist_length(ql); +} + +void * ql_replace(struct quicklist *ql, int index, void *el) +{ + return selist_replace(ql, index, el); +} + +void *ql_get(struct quicklist *ql, int index) +{ + return selist_get(ql, index); +} + +int ql_delete(struct quicklist **qlp, int index) +{ + return selist_delete(qlp, index); +} + +bool ql_empty(const struct quicklist *ql) +{ + return selist_empty(ql); +} + +void ql_foreach(struct quicklist *ql, selist_cb cb) +{ + selist_foreach(ql, cb); +} + +int ql_advance(struct quicklist **qlp, int *index, int stride) +{ + return selist_advance(qlp, index, stride); +} + +void ql_free(struct quicklist *ql) +{ + selist_free(ql); +} + bool ql_set_remove(struct quicklist **qlp, const void *data) { int qi, qn; diff --git a/src/quicklist.h b/src/quicklist.h index c0446b471..f5a85a354 100644 --- a/src/quicklist.h +++ b/src/quicklist.h @@ -1,18 +1,17 @@ #pragma once #define selist quicklist -#define selist_free ql_free -#define selist_delete ql_delete -#define selist_foreach ql_foreach -#define selist_get ql_get -#define selist_replace ql_replace -#define selist_length ql_length -#define selist_push ql_push -#define selist_empty ql_empty -#define selist_advance ql_advance #include -#include +int ql_advance(struct quicklist **qlp, int *index, int stride); +void ql_foreach(struct quicklist *ql, selist_cb cb); +void ql_free(struct quicklist *ql); +int ql_delete(struct quicklist **qlp, int index); +void ql_push(struct quicklist **qlp, void *el); +int ql_length(const struct quicklist *ql); +void * ql_replace(struct quicklist *ql, int index, void *el); +void *ql_get(struct quicklist *ql, int index); +bool ql_empty(const struct quicklist *ql); typedef void(*ql_cb)(void *); bool ql_set_insert_ex(struct quicklist **qlp, void *data, int (*cmp_cb)(const void *lhs, const void *rhs)); bool ql_set_find_ex(struct quicklist **qlp, int *qip, const void *data, int (*cmp_cb)(const void *lhs, const void *rhs)); diff --git a/src/reports.c b/src/reports.c index a8b9e5cfb..3e139fdda 100644 --- a/src/reports.c +++ b/src/reports.c @@ -989,7 +989,7 @@ int cmp_faction(const void *lhs, const void *rhs) { } static void add_seen_faction_i(struct quicklist **flist, faction *f) { - ql_set_insert_ex(flist, f, cmp_faction); + selist_set_insert(flist, f, cmp_faction); } void add_seen_faction(faction *self, faction *seen) {