summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2019-05-22 11:32:11 +0200
committerGravatar Nikias Bassen2019-05-22 11:32:11 +0200
commita6b542b389d0536d2730c1721164a712ec2f020e (patch)
tree52d7010bcf314c1969b0be12f1e49765f2200c77 /common
parent9efb1745bf0eb68064a670b297d4ec7fc98caa02 (diff)
downloadlibusbmuxd-a6b542b389d0536d2730c1721164a712ec2f020e.tar.gz
libusbmuxd-a6b542b389d0536d2730c1721164a712ec2f020e.tar.bz2
Add new usbmuxd_events_subscribe/unsubscribe functions with a context so it can be used in different threads
Diffstat (limited to 'common')
-rw-r--r--common/collection.c5
-rw-r--r--common/collection.h2
2 files changed, 4 insertions, 3 deletions
diff --git a/common/collection.c b/common/collection.c
index ccc4016..d120b3e 100644
--- a/common/collection.c
+++ b/common/collection.c
@@ -57,16 +57,17 @@ void collection_add(struct collection *col, void *element)
col->capacity *= 2;
}
-void collection_remove(struct collection *col, void *element)
+int collection_remove(struct collection *col, void *element)
{
int i;
for(i=0; i<col->capacity; i++) {
if(col->list[i] == element) {
col->list[i] = NULL;
- return;
+ return 0;
}
}
fprintf(stderr, "%s: WARNING: element %p not present in collection %p (cap %d)", __func__, element, col, col->capacity);
+ return -1;
}
int collection_count(struct collection *col)
diff --git a/common/collection.h b/common/collection.h
index a91a465..47b9b7f 100644
--- a/common/collection.h
+++ b/common/collection.h
@@ -29,7 +29,7 @@ struct collection {
void collection_init(struct collection *col);
void collection_add(struct collection *col, void *element);
-void collection_remove(struct collection *col, void *element);
+int collection_remove(struct collection *col, void *element);
int collection_count(struct collection *col);
void collection_free(struct collection *col);