]> sigrok.org Git - libsigrok.git/commitdiff
serial-dmm: Drop unneeded g_try_malloc0().
authorUwe Hermann <redacted>
Sat, 2 Feb 2013 11:22:18 +0000 (12:22 +0100)
committerUwe Hermann <redacted>
Sat, 2 Feb 2013 11:34:25 +0000 (12:34 +0100)
hardware/serial-dmm/protocol.c

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