summaryrefslogtreecommitdiff
path: root/decoder.c
diff options
context:
space:
mode:
authorBert Vermeulen <bert@biot.com>2012-01-31 23:48:10 +0100
committerBert Vermeulen <bert@biot.com>2012-01-31 23:48:10 +0100
commitfa12a21e3c779df4e33dcfe394e2ded3f96028ce (patch)
treec3c26fc8dfb6a5670045389de80662f28982f3ee /decoder.c
parentdbeaab27a4537863a5d7a8180af2de57ba55f1d4 (diff)
downloadlibsigrokdecode-fa12a21e3c779df4e33dcfe394e2ded3f96028ce.tar.gz
libsigrokdecode-fa12a21e3c779df4e33dcfe394e2ded3f96028ce.zip
srd: free all decoder instances when unloading decoders
Diffstat (limited to 'decoder.c')
-rw-r--r--decoder.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/decoder.c b/decoder.c
index efb1f9a..83735a7 100644
--- a/decoder.c
+++ b/decoder.c
@@ -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->extra_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? */