/** @cond PRIVATE */
-/* The list of protocol decoders. */
+/* The list of loaded protocol decoders. */
static GSList *pd_list = NULL;
/* srd.c */
}
/**
- * Returns the list of supported/loaded protocol decoders.
+ * Returns the list of loaded protocol decoders.
*
* This is a GSList of pointers to struct srd_decoder items.
*
*/
SRD_API int srd_decoder_load(const char *module_name)
{
- PyObject *py_modname, *py_basedec, *py_apiver;
+ PyObject *py_basedec, *py_apiver;
struct srd_decoder *d;
long apiver;
int is_subclass;
d = g_malloc0(sizeof(struct srd_decoder));
- /* Import the Python module. */
- py_modname = PyUnicode_FromString(module_name);
- if (!py_modname)
- goto except_out;
-
- d->py_mod = PyImport_Import(py_modname);
- Py_DECREF(py_modname);
+ d->py_mod = py_import_by_name(module_name);
if (!d->py_mod)
goto except_out;
if (get_binary_classes(d) != SRD_OK)
goto err_out;
- /* Append it to the list of supported/loaded decoders. */
+ /* Append it to the list of loaded decoders. */
pd_list = g_slist_append(pd_list, d);
return SRD_OK;
srd_inst_free_all(sess, NULL);
}
+ /* Remove the PD from the list of loaded decoders. */
+ pd_list = g_slist_remove(pd_list, dec);
+
decoder_free(dec);
return SRD_OK;
char *prefix;
size_t prefix_len;
- zipimport_mod = NULL;
set = files = prefix_obj = zipimporter = zipimporter_class = NULL;
- modname = PyUnicode_FromString("zipimport");
- if (!modname)
- goto err_out;
-
- zipimport_mod = PyImport_Import(modname);
- Py_DECREF(modname);
+ zipimport_mod = py_import_by_name("zipimport");
if (zipimport_mod == NULL)
goto err_out;