summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--decoder.c10
-rw-r--r--srd.c11
2 files changed, 17 insertions, 4 deletions
diff --git a/decoder.c b/decoder.c
index 7374b77..260f636 100644
--- a/decoder.c
+++ b/decoder.c
@@ -1068,6 +1068,13 @@ SRD_API int srd_decoder_load_all(void)
return SRD_OK;
}
+static void srd_decoder_unload_cb(void *arg, void *ignored)
+{
+ (void)ignored;
+
+ srd_decoder_unload((struct srd_decoder *)arg);
+}
+
/**
* Unload all loaded protocol decoders.
*
@@ -1077,8 +1084,7 @@ SRD_API int srd_decoder_load_all(void)
*/
SRD_API int srd_decoder_unload_all(void)
{
- for (GSList *l = pd_list; l; l = l->next)
- srd_decoder_unload(l->data);
+ g_slist_foreach(pd_list, srd_decoder_unload_cb, NULL);
g_slist_free(pd_list);
pd_list = NULL;
diff --git a/srd.c b/srd.c
index 535ea12..248d8e5 100644
--- a/srd.c
+++ b/srd.c
@@ -289,6 +289,12 @@ SRD_API int srd_init(const char *path)
return SRD_OK;
}
+static void srd_session_destroy_cb(void *arg, void *ignored)
+{
+ (void)ignored; // Prevent unused warning
+ srd_session_destroy((struct srd_session *)arg);
+}
+
/**
* Shutdown libsigrokdecode.
*
@@ -307,8 +313,9 @@ SRD_API int srd_exit(void)
{
srd_dbg("Exiting libsigrokdecode.");
- for (GSList *l = sessions; l; l = l->next)
- srd_session_destroy(l->data);
+ g_slist_foreach(sessions, srd_session_destroy_cb, NULL);
+ g_slist_free(sessions);
+ sessions = NULL;
srd_decoder_unload_all();
g_slist_free_full(searchpaths, g_free);