X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=decoder.c;h=64292bc7077452abb45caba3de6b728546824f44;hp=8ad0c5a132e1bac021184bab8c9ee60e28aa5ff6;hb=d399c64172cdf99637b63b01d2af1e509ed6b059;hpb=21dfd91d99836bdc6c0da939b601dd8a52358f21 diff --git a/decoder.c b/decoder.c index 8ad0c5a..64292bc 100644 --- a/decoder.c +++ b/decoder.c @@ -165,6 +165,8 @@ static void decoder_free(struct srd_decoder *dec) g_slist_free_full(dec->opt_channels, &channel_free); g_slist_free_full(dec->channels, &channel_free); + g_slist_free_full(dec->outputs, g_free); + g_slist_free_full(dec->inputs, g_free); g_free(dec->license); g_free(dec->desc); g_free(dec->longname); @@ -592,6 +594,8 @@ static int check_method(PyObject *py_dec, const char *mod_name, * @param d The decoder to use. Must not be NULL. * * @return The API version of the decoder, or 0 upon errors. + * + * @private */ SRD_PRIV long srd_decoder_apiver(const struct srd_decoder *d) { @@ -727,6 +731,16 @@ SRD_API int srd_decoder_load(const char *module_name) goto err_out; } + if (py_attr_as_strlist(d->py_dec, "inputs", &(d->inputs)) != SRD_OK) { + fail_txt = "missing or malformed 'inputs' attribute"; + goto err_out; + } + + if (py_attr_as_strlist(d->py_dec, "outputs", &(d->outputs)) != SRD_OK) { + fail_txt = "missing or malformed 'outputs' attribute"; + goto err_out; + } + /* All options and their default values. */ if (get_options(d) != SRD_OK) { fail_txt = "cannot get options"; @@ -767,13 +781,12 @@ SRD_API int srd_decoder_load(const char *module_name) return SRD_OK; except_out: - if (fail_txt) { + /* Don't show a message for the "common" directory, it's not a PD. */ + if (strcmp(module_name, "common")) { srd_exception_catch("Failed to load decoder %s: %s", module_name, fail_txt); - fail_txt = NULL; - } else { - srd_exception_catch("Failed to load decoder %s", module_name); } + fail_txt = NULL; err_out: if (fail_txt) srd_err("Failed to load decoder %s: %s", module_name, fail_txt); @@ -849,7 +862,7 @@ SRD_API int srd_decoder_unload(struct srd_decoder *dec) */ for (l = sessions; l; l = l->next) { sess = l->data; - srd_inst_free_all(sess, NULL); + srd_inst_free_all(sess); } /* Remove the PD from the list of loaded decoders. */