X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=type_decoder.c;h=16e25a7b92f8885dd22f11fb344cb30b9cd98d2c;hp=06842f9e9069230a44b03fef24e8cc5838a341c3;hb=b939fdff17225ec1eb24aad816f8a2018a9d4079;hpb=7d82e3c1ec96ac8a9ef358de1e9c87715dcb8f43 diff --git a/type_decoder.c b/type_decoder.c index 06842f9..16e25a7 100644 --- a/type_decoder.c +++ b/type_decoder.c @@ -40,6 +40,15 @@ static const char *output_type_name(unsigned int idx) return names[MIN(idx, G_N_ELEMENTS(names) - 1)]; } +static void release_annotation(struct srd_proto_data_annotation *pda) +{ + if (!pda) + return; + if (pda->ann_text) + g_strfreev(pda->ann_text); + g_free(pda); +} + static int convert_annotation(struct srd_decoder_inst *di, PyObject *obj, struct srd_proto_data *pdata) { @@ -112,6 +121,15 @@ err: return SRD_ERR_PYTHON; } +static void release_binary(struct srd_proto_data_binary *pdb) +{ + if (!pdb) + return; + if (pdb->data) + g_free((void *)pdb->data); + g_free(pdb); +} + static int convert_binary(struct srd_decoder_inst *di, PyObject *obj, struct srd_proto_data *pdata) { @@ -229,6 +247,13 @@ err: return SRD_ERR_PYTHON; } +static void release_meta(GVariant *gvar) +{ + if (!gvar) + return; + g_variant_unref(gvar); +} + static PyObject *Decoder_put(PyObject *self, PyObject *args) { GSList *l; @@ -241,6 +266,8 @@ static PyObject *Decoder_put(PyObject *self, PyObject *args) struct srd_pd_callback *cb; PyGILState_STATE gstate; + py_data = NULL; + gstate = PyGILState_Ensure(); if (!(di = srd_inst_find_by_obj(NULL, self))) { @@ -287,6 +314,7 @@ static PyObject *Decoder_put(PyObject *self, PyObject *args) Py_BEGIN_ALLOW_THREADS cb->cb(&pdata, cb->cb_data); Py_END_ALLOW_THREADS + release_annotation(pdata.data); } break; case SRD_OUTPUT_PYTHON: @@ -319,6 +347,7 @@ static PyObject *Decoder_put(PyObject *self, PyObject *args) Py_BEGIN_ALLOW_THREADS cb->cb(&pdata, cb->cb_data); Py_END_ALLOW_THREADS + release_binary(pdata.data); } break; case SRD_OUTPUT_META: @@ -331,6 +360,7 @@ static PyObject *Decoder_put(PyObject *self, PyObject *args) Py_BEGIN_ALLOW_THREADS cb->cb(&pdata, cb->cb_data); Py_END_ALLOW_THREADS + release_meta(pdata.data); } break; default: @@ -398,8 +428,6 @@ static PyObject *Decoder_register(PyObject *self, PyObject *args, } } - srd_dbg("Instance %s checking registration type %d for %s.", - di->inst_id, output_type, proto_id); pdo = NULL; for (l = di->pd_output; l; l = l->next) { cmp = l->data;