X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=instance.c;h=6b8d6b45a2d3b4d868e8e187131895f5101e98eb;hp=92959635b5e34ad95771714c921bdded3e8d0b3a;hb=37b94c205e4c1c43e77e29993108f23066cbce05;hpb=a3a2a26d2a93d1fe7a3bb2e8eb732509c8c905e6 diff --git a/instance.c b/instance.c index 9295963..6b8d6b4 100644 --- a/instance.c +++ b/instance.c @@ -373,8 +373,18 @@ SRD_API struct srd_decoder_inst *srd_inst_new(struct srd_session *sess, } for (i = 0; i < di->dec_num_probes; i++) di->dec_probemap[i] = i; + di->data_unitsize = (di->dec_num_probes + 7) / 8; + /* + * Will be used to prepare a sample at every iteration + * of the instance's decode() method. + */ + if (!(di->probe_samples = g_try_malloc(di->dec_num_probes))) { + srd_err("Failed to g_malloc() sample buffer."); + g_free(di->dec_probemap); + g_free(di); + return NULL; + } } - di->data_unitsize = (di->dec_num_probes + 7) / 8; /* Create a new instance of this decoder class. */ if (!(di->py_inst = PyObject_CallObject(dec->py_dec, NULL))) {