X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=decoder.c;h=01dcf0a823b6da56a798d646750e355bfdd3de52;hp=c8eb98fb1b641103f0c7548eaf4f942956cd1e45;hb=269b442df38c1cfe825fd397612f8f79aea5541d;hpb=8c664ca2d7b4faffa7b3dbeb3b9e491976c24eee diff --git a/decoder.c b/decoder.c index c8eb98f..01dcf0a 100644 --- a/decoder.c +++ b/decoder.c @@ -19,8 +19,8 @@ */ #include "config.h" -#include "sigrokdecode.h" /* First, so we avoid a _POSIX_C_SOURCE warning. */ -#include "sigrokdecode-internal.h" +#include "libsigrokdecode.h" /* First, so we avoid a _POSIX_C_SOURCE warning. */ +#include "libsigrokdecode-internal.h" #include /** @@ -42,6 +42,8 @@ /* The list of protocol decoders. */ SRD_PRIV GSList *pd_list = NULL; +extern GSList *sessions; + /* module_sigrokdecode.c */ extern SRD_PRIV PyObject *mod_sigrokdecode; @@ -217,6 +219,8 @@ static int get_options(struct srd_decoder *d) } g_variant_ref_sink(o->def); d->options = g_slist_append(d->options, o); + g_free(key); + key = NULL; } Py_DecRef(py_keys); Py_DecRef(py_values); @@ -248,6 +252,9 @@ SRD_API int srd_decoder_load(const char *module_name) struct srd_probe *p; GSList *l; + if (!module_name) + return SRD_ERR_ARG; + srd_dbg("Loading protocol decoder '%s'.", module_name); py_basedec = py_method = py_attr = NULL; @@ -448,7 +455,7 @@ static void free_probes(GSList *probelist) } /** - * Unload decoder module. + * Unload the specified protocol decoder. * * @param dec The struct srd_decoder to be unloaded. * @@ -459,6 +466,7 @@ static void free_probes(GSList *probelist) SRD_API int srd_decoder_unload(struct srd_decoder *dec) { struct srd_decoder_option *o; + struct srd_session *sess; GSList *l; srd_dbg("Unloading protocol decoder '%s'.", dec->name); @@ -469,7 +477,10 @@ SRD_API int srd_decoder_unload(struct srd_decoder *dec) * stack. A frontend reloading a decoder thus has to restart all * instances, and rebuild the stack. */ - srd_inst_free_all(NULL); + for (l = sessions; l; l = l->next) { + sess = l->data; + srd_inst_free_all(sess, NULL); + } for (l = dec->options; l; l = l->next) { o = l->data; @@ -493,7 +504,7 @@ SRD_API int srd_decoder_unload(struct srd_decoder *dec) /* The module itself. */ Py_XDECREF(dec->py_mod); - /* TODO: (g_)free dec itself? */ + g_free(dec); return SRD_OK; }