From 14a5ba837f78bca9d524d29b9800869173fe45ba Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Wed, 1 May 2024 07:42:19 +0530 Subject: npassd/service/service_free: free collections --- include/npassd/collection.h | 1 + src/npassd/collection.c | 2 +- src/npassd/service.c | 9 ++++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/npassd/collection.h b/include/npassd/collection.h index 36d6b72..40c100f 100644 --- a/include/npassd/collection.h +++ b/include/npassd/collection.h @@ -16,6 +16,7 @@ struct collection { LIST_HEAD(collection_dlist, collection); +void collection_free(struct collection *c); int collection_new(sd_bus *bus, struct sqlite3 *db, struct collection **p, const char *alias, const char *label, const char *root); int collection_root_make(const char *label, const char *alias, char **root); diff --git a/src/npassd/collection.c b/src/npassd/collection.c index ff5ffae..a190b79 100644 --- a/src/npassd/collection.c +++ b/src/npassd/collection.c @@ -40,7 +40,7 @@ static int handle_create_item(__attribute__((unused)) sd_bus_message *msg, return 0; } -static void collection_free(struct collection *c) +void collection_free(struct collection *c) { if (c == NULL) return; diff --git a/src/npassd/service.c b/src/npassd/service.c index e57fefe..8fa1b19 100644 --- a/src/npassd/service.c +++ b/src/npassd/service.c @@ -149,10 +149,13 @@ static int handle_open_session(sd_bus_message *msg, void *data, void service_free(struct service *service) { - struct session *p; + struct session *s; + struct collection *c; - LIST_FOREACH(p, &service->sessions, dlist) - session_free(p); + LIST_FOREACH(s, &service->sessions, dlist) + session_free(s); + LIST_FOREACH(c, &service->collections, dlist) + collection_free(c); sd_bus_slot_unref(service->slot); } -- cgit v1.2.3