X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=blobdiff_plain;f=src%2Fhardware%2Fsiglent-sds%2Fprotocol.c;h=fde58d003e524e1f52b7ab596cf6e5b2b4649b51;hp=8fced83afddd1a55b6549cf29770fc0fba584b4f;hb=70158398f3446881eee8493e8f6d2599f26a1c18;hpb=4da62209ddfa3aad12678c7141c19e9c3e8419c1 diff --git a/src/hardware/siglent-sds/protocol.c b/src/hardware/siglent-sds/protocol.c index 8fced83a..fde58d00 100644 --- a/src/hardware/siglent-sds/protocol.c +++ b/src/hardware/siglent-sds/protocol.c @@ -75,6 +75,7 @@ static int siglent_sds_event_wait(const struct sr_dev_inst *sdi) if (sr_scpi_get_string(sdi->conn, ":INR?", &buf) != SR_OK) return SR_ERR; sr_atoi(buf, &out); + g_free(buf); g_usleep(s); } while (out == 0); @@ -100,6 +101,7 @@ static int siglent_sds_event_wait(const struct sr_dev_inst *sdi) if (sr_scpi_get_string(sdi->conn, ":INR?", &buf) != SR_OK) return SR_ERR; sr_atoi(buf, &out); + g_free(buf); g_usleep(s); /* XXX * Now this loop condition looks suspicious! A bitwise @@ -168,6 +170,7 @@ SR_PRIV int siglent_sds_capture_start(const struct sr_dev_inst *sdi) if (sr_scpi_get_string(sdi->conn, ":INR?", &buf) != SR_OK) return SR_ERR; sr_atoi(buf, &out); + g_free(buf); if (out == DEVICE_STATE_TRIG_RDY) { siglent_sds_set_wait_event(devc, WAIT_TRIGGER); } else if (out == DEVICE_STATE_DATA_TRIG_RDY) { @@ -217,6 +220,7 @@ SR_PRIV int siglent_sds_capture_start(const struct sr_dev_inst *sdi) if (sr_scpi_get_string(sdi->conn, ":INR?", &buf) != SR_OK) return SR_ERR; sr_atoi(buf, &out); + g_free(buf); if (out == DEVICE_STATE_TRIG_RDY) { siglent_sds_set_wait_event(devc, WAIT_TRIGGER); } else if (out == DEVICE_STATE_DATA_TRIG_RDY) { @@ -760,6 +764,8 @@ SR_PRIV int siglent_sds_get_dev_cfg(const struct sr_dev_inst *sdi) /* Coupling. */ for (i = 0; i < devc->model->analog_channels; i++) { cmd = g_strdup_printf("C%d:CPL?", i + 1); + g_free(devc->coupling[i]); + devc->coupling[i] = NULL; res = sr_scpi_get_string(sdi->conn, cmd, &devc->coupling[i]); g_free(cmd); if (res != SR_OK) @@ -813,6 +819,8 @@ SR_PRIV int siglent_sds_get_dev_cfg(const struct sr_dev_inst *sdi) /* Trigger slope. */ cmd = g_strdup_printf("%s:TRSL?", devc->trigger_source); + g_free(devc->trigger_slope); + devc->trigger_slope = NULL; res = sr_scpi_get_string(sdi->conn, cmd, &devc->trigger_slope); g_free(cmd); if (res != SR_OK) @@ -886,12 +894,15 @@ SR_PRIV int siglent_sds_get_dev_cfg_horizontal(const struct sr_dev_inst *sdi) g_free(cmd); samplerate_scope = 0; fvalue = 0; - if (res != SR_OK) + if (res != SR_OK) { + g_free(sample_points_string); return SR_ERR; + } if (g_strstr_len(sample_points_string, -1, "Mpts") != NULL) { sample_points_string[strlen(sample_points_string) - 4] = '\0'; if (sr_atof_ascii(sample_points_string, &fvalue) != SR_OK) { sr_dbg("Invalid float converted from scope response."); + g_free(sample_points_string); return SR_ERR; } samplerate_scope = fvalue * 1000000; @@ -899,6 +910,7 @@ SR_PRIV int siglent_sds_get_dev_cfg_horizontal(const struct sr_dev_inst *sdi) sample_points_string[strlen(sample_points_string) - 4] = '\0'; if (sr_atof_ascii(sample_points_string, &fvalue) != SR_OK) { sr_dbg("Invalid float converted from scope response."); + g_free(sample_points_string); return SR_ERR; } samplerate_scope = fvalue * 10000;