X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=decoder.c;h=6f4a88dbeb740e05d99d6677c15d3c970fd7385a;hp=efb1f9ae4bdd8b2ac827a2aec123455178cf53aa;hb=dcdf48838748df02bc3028c4a26ea6d4506ee542;hpb=6fff00eee1dd62477cd2708df480b985ef416a67 diff --git a/decoder.c b/decoder.c index efb1f9a..6f4a88d 100644 --- a/decoder.c +++ b/decoder.c @@ -220,7 +220,7 @@ int srd_load_decoder(const char *name, struct srd_decoder **dec) goto err_out; /* Check and import optional probes. */ - if (get_probes(d, "extra_probes", &d->extra_probes) != SRD_OK) + if (get_probes(d, "optional_probes", &d->opt_probes) != SRD_OK) goto err_out; /* Store required fields in newly allocated strings. */ @@ -304,16 +304,45 @@ char *srd_decoder_doc(struct srd_decoder *dec) } +static void free_probes(GSList *probelist) +{ + GSList *l; + struct srd_probe *p; + + if (probelist == NULL) + return; + + for (l = probelist; l; l = l->next) { + p = l->data; + g_free(p->id); + g_free(p->name); + g_free(p->desc); + g_free(p); + } + g_slist_free(probelist); + +} + /** * Unload decoder module. * - * @param dec The decoder struct to be unloaded. + * @param dec The struct srd_decoder to be unloaded. * * @return SRD_OK upon success, a (negative) error code otherwise. */ int srd_unload_decoder(struct srd_decoder *dec) { + srd_dbg("unloading decoder %s", dec->name); + + /* Since any instances of this decoder need to be released as well, + * but they could be anywhere in the stack, just free the entire + * stack. A frontend reloading a decoder thus has to restart all + * instances, and rebuild the stack. */ + srd_instance_free_all(NULL); + + free_probes(dec->probes); + free_probes(dec->opt_probes); g_free(dec->id); g_free(dec->name); g_free(dec->longname); @@ -326,7 +355,9 @@ int srd_unload_decoder(struct srd_decoder *dec) if (dec->outputformats != NULL) g_slist_free(dec->outputformats); + /* The module's Decoder class. */ Py_XDECREF(dec->py_dec); + /* The module itself. */ Py_XDECREF(dec->py_mod); /* TODO: (g_)free dec itself? */