From 91701367ad7f2a2ac7c35ea9ed796b0a4a2a0b12 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Thu, 12 Sep 2019 18:01:35 +0200 Subject: Added function to count subscriptions --- common/subscriptions.c | 5 +++++ common/subscriptions.h | 1 + 2 files changed, 6 insertions(+) diff --git a/common/subscriptions.c b/common/subscriptions.c index 9c8c345..529c339 100644 --- a/common/subscriptions.c +++ b/common/subscriptions.c @@ -38,3 +38,8 @@ void common_subscriptions_const_walk(const struct subscription* subscriptions, v func(sub); } } + +size_t common_subscriptions_count(const struct subscription* subscriptions) +{ + return HASH_COUNT(subscriptions); +} diff --git a/common/subscriptions.h b/common/subscriptions.h index 0ade221..3e195bb 100644 --- a/common/subscriptions.h +++ b/common/subscriptions.h @@ -25,5 +25,6 @@ void common_subscription_add(struct subscription** subscriptions, const char* id struct subscription* common_subscription_new(const char* rid, const char* name, enum subscription_type type, size_t unread); void common_subscriptions_free(struct subscription* subscriptions); void common_subscriptions_const_walk(const struct subscription* subscriptions, void (*func)(const struct subscription*)); +size_t common_subscriptions_count(const struct subscription* subscriptions); #endif -- cgit v1.2.3