]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoder.c
configure.ac: Bump package version to 0.5.3.
[libsigrokdecode.git] / decoder.c
index 7374b779453e015025b59ae6dc4b5f16e5416e09..1a9defb23e1a9764c1fd0d0f781308efc11a1d28 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. */
 
+       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;
@@ -858,7 +863,7 @@ err_out:
 /**
  * Return a protocol decoder's docstring.
  *
- * @param dec The loaded protocol decoder.
+ * @param dec The loaded protocol decoder. Must not be NULL.
  *
  * @return A newly allocated buffer containing the protocol decoder's
  *         documentation. The caller is responsible for free'ing the buffer.
@@ -874,7 +879,7 @@ SRD_API char *srd_decoder_doc_get(const struct srd_decoder *dec)
        if (!srd_check_init())
                return NULL;
 
-       if (!dec)
+       if (!dec || !dec->py_mod)
                return NULL;
 
        gstate = PyGILState_Ensure();
@@ -1068,6 +1073,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 +1089,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;