+ Py_XDECREF(py_res);
+
+err_run_decref_args:
+ Py_XDECREF(py_args);
+err_run_decref_func:
+ Py_XDECREF(py_func);
+ Py_XDECREF(py_mod);
+
+ if (PyErr_Occurred())
+ PyErr_Print(); /* Returns void. */
+
+ return ret;
+}
+
+/**
+ * TODO
+ */
+static int srd_unload_decoder(struct srd_decoder *dec)
+{
+ g_free(dec->id);
+ g_free(dec->name);
+ g_free(dec->desc);
+ g_free(dec->func);
+
+ /* TODO: Free everything in inputformats and outputformats. */
+
+ if (dec->inputformats != NULL)
+ g_slist_free(dec->inputformats);
+ if (dec->outputformats != NULL)
+ g_slist_free(dec->outputformats);
+
+ Py_XDECREF(dec->py_func);
+ Py_XDECREF(dec->py_mod);
+
+ return SRD_OK;
+}
+
+/**
+ * TODO
+ */
+static int srd_unload_all_decoders(void)
+{
+ GSList *l;
+ struct srd_decoder *dec;
+
+ for (l = srd_list_decoders(); l; l = l->next) {
+ dec = l->data;
+ /* TODO: Error handling. */
+ srd_unload_decoder(dec);
+ }
+
+ return SRD_OK;