summaryrefslogtreecommitdiffstats
path: root/src/ref.c
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2023-11-12 19:45:08 +0100
committerLouis Burda <quent.burda@gmail.com>2023-11-12 20:46:57 +0100
commit049d23ab28f2708506dbde362539e9b5f36a10c4 (patch)
treea9a64494a0c8662ac2431d9d70ac18b5c89329a5 /src/ref.c
parentf868887d311cbb330732587c89ab9d886dfa4693 (diff)
downloadtmus-049d23ab28f2708506dbde362539e9b5f36a10c4.tar.gz
tmus-049d23ab28f2708506dbde362539e9b5f36a10c4.zip
Update liblist api and remote
Diffstat (limited to 'src/ref.c')
-rw-r--r--src/ref.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/ref.c b/src/ref.c
index 4960852..b628d51 100644
--- a/src/ref.c
+++ b/src/ref.c
@@ -1,6 +1,9 @@
#include "ref.h"
+#include "list.h"
#include "util.h"
+#include <stdlib.h>
+
struct ref *
ref_alloc(void *data)
{
@@ -9,7 +12,7 @@ ref_alloc(void *data)
ref = malloc(sizeof(struct ref));
if (!ref) ERROR(SYSTEM, "malloc");
- ref->link = LINK_EMPTY;
+ ref->link = LIST_LINK_INIT;
ref->data = data;
return ref;
@@ -24,19 +27,19 @@ ref_free(void *ref)
void
refs_free(struct list *list)
{
- list_free(list, ref_free, LINK_OFFSET(struct ref, link));
+ list_free_items(list, ref_free, LIST_OFFSET(struct ref, link));
}
int
refs_index(struct list *list, void *data)
{
- struct link *iter;
+ struct list_link *iter;
struct ref *ref;
int index;
index = 0;
for (LIST_ITER(list, iter)) {
- ref = UPCAST(iter, struct ref, link);
+ ref = LIST_UPCAST(iter, struct ref, link);
if (ref->data == data)
return index;
index++;
@@ -45,14 +48,14 @@ refs_index(struct list *list, void *data)
return -1;
}
-struct link *
+struct list_link *
refs_find(struct list *list, void *data)
{
- struct link *iter;
+ struct list_link *iter;
struct ref *ref;
for (LIST_ITER(list, iter)) {
- ref = UPCAST(iter, struct ref, link);
+ ref = LIST_UPCAST(iter, struct ref, link);
if (ref->data == data)
return iter;
}
@@ -63,7 +66,7 @@ refs_find(struct list *list, void *data)
int
refs_incl(struct list *list, void *data)
{
- struct link *ref;
+ struct list_link *ref;
ref = refs_find(list, data);
@@ -73,14 +76,14 @@ refs_incl(struct list *list, void *data)
void
refs_rm(struct list *list, void *data)
{
- struct link *ref;
+ struct list_link *ref;
struct ref *dataref;
ref = refs_find(list, data);
if (!ref) return;
- dataref = UPCAST(ref, struct ref, link);
- link_pop(ref);
+ dataref = LIST_UPCAST(ref, struct ref, link);
+ list_link_pop(ref);
free(dataref);
}