X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=type_decoder.c;h=16e25a7b92f8885dd22f11fb344cb30b9cd98d2c;hp=880dbade0a7697d054308001b1e3a66b988d829c;hb=b939fdff17225ec1eb24aad816f8a2018a9d4079;hpb=fb0b05e68352a55e1d8a212413df40d90a30202c diff --git a/type_decoder.c b/type_decoder.c index 880dbad..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: