]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoder.c
decoder: consider reset() a mandatory decoder method
[libsigrokdecode.git] / decoder.c
index 7374b779453e015025b59ae6dc4b5f16e5416e09..2eb9a573136cb206bffc4c30a052b2ebb9c76f49 100644 (file)
--- a/decoder.c
+++ b/decoder.c
@@ -751,6 +751,11 @@ SRD_API int srd_decoder_load(const char *module_name)
 
        /* Check Decoder class for required methods. */
 
 
        /* Check Decoder class for required methods. */
 
+       if (check_method(d->py_dec, module_name, "reset") != SRD_OK) {
+               fail_txt = "no 'reset()' method";
+               goto err_out;
+       }
+
        if (check_method(d->py_dec, module_name, "start") != SRD_OK) {
                fail_txt = "no 'start()' method";
                goto err_out;
        if (check_method(d->py_dec, module_name, "start") != SRD_OK) {
                fail_txt = "no 'start()' method";
                goto err_out;
@@ -1068,6 +1073,13 @@ SRD_API int srd_decoder_load_all(void)
        return SRD_OK;
 }
 
        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.
  *
 /**
  * Unload all loaded protocol decoders.
  *
@@ -1077,8 +1089,7 @@ SRD_API int srd_decoder_load_all(void)
  */
 SRD_API int srd_decoder_unload_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;
 
        g_slist_free(pd_list);
        pd_list = NULL;