serial-dmm: Drop unneeded g_try_malloc0().

This commit is contained in:
Uwe Hermann 2013-02-02 12:22:18 +01:00
parent bf6f8399fc
commit 7c8a9e1e0f
1 changed files with 10 additions and 15 deletions

View File

@ -90,37 +90,32 @@ static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi,
{ {
float floatval; float floatval;
struct sr_datafeed_packet packet; struct sr_datafeed_packet packet;
struct sr_datafeed_analog *analog; struct sr_datafeed_analog analog;
struct dev_context *devc; struct dev_context *devc;
log_dmm_packet(buf); log_dmm_packet(buf);
devc = sdi->priv; devc = sdi->priv;
if (!(analog = g_try_malloc0(sizeof(struct sr_datafeed_analog)))) { memset(&analog, 0, sizeof(struct sr_datafeed_analog));
sr_err("Analog packet malloc failed.");
return;
}
analog->probes = sdi->probes; analog.probes = sdi->probes;
analog->num_samples = 1; analog.num_samples = 1;
analog->mq = -1; analog.mq = -1;
dmms[dmm].packet_parse(buf, &floatval, analog, info); dmms[dmm].packet_parse(buf, &floatval, &analog, info);
analog->data = &floatval; analog.data = &floatval;
/* If this DMM needs additional handling, call the resp. function. */ /* If this DMM needs additional handling, call the resp. function. */
if (dmms[dmm].dmm_details) if (dmms[dmm].dmm_details)
dmms[dmm].dmm_details(analog, info); dmms[dmm].dmm_details(&analog, info);
if (analog->mq != -1) { if (analog.mq != -1) {
/* Got a measurement. */ /* Got a measurement. */
packet.type = SR_DF_ANALOG; packet.type = SR_DF_ANALOG;
packet.payload = analog; packet.payload = &analog;
sr_session_send(devc->cb_data, &packet); sr_session_send(devc->cb_data, &packet);
devc->num_samples++; devc->num_samples++;
} }
g_free(analog);
} }
static void handle_new_data(struct sr_dev_inst *sdi, int dmm, void *info) static void handle_new_data(struct sr_dev_inst *sdi, int dmm, void *info)