sdi->vendor = g_strdup("Agilent");
sdi->model = g_strdup(tokens[1]);
sdi->version = g_strdup(tokens[3]);
- if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_err("Device context malloc failed.");
- return NULL;
- }
+ devc = g_malloc0(sizeof(struct dev_context));
devc->profile = &supported_agdmm[i];
devc->cur_mq = -1;
sdi->inst_type = SR_INST_SERIAL;
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("APPA");
sdi->model = g_strdup("55II");
-
- if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_err("Device context malloc failed.");
- goto scan_cleanup;
- }
-
+ devc = g_malloc0(sizeof(struct dev_context));
devc->data_source = DEFAULT_DATA_SOURCE;
-
sdi->inst_type = SR_INST_SERIAL;
sdi->conn = serial;
sdi->priv = devc;
devices = NULL;
- if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
- sr_err("%s: devc malloc failed", __func__);
- return NULL;
- }
+ devc = g_malloc0(sizeof(struct dev_context));
ftdi_init(&devc->ftdic);
return std_init(sr_ctx, di, LOG_PREFIX);
}
-static struct dev_context * beaglelogic_devc_alloc(void)
+static struct dev_context *beaglelogic_devc_alloc(void)
{
struct dev_context *devc;
- /* Allocate zeroed structure */
- devc = g_try_malloc0(sizeof(*devc));
+ devc = g_malloc0(sizeof(struct dev_context));
/* Default non-zero values (if any) */
devc->fd = -1;
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("Brymen");
sdi->model = g_strdup("BM869");
-
- if (!(devc = g_try_malloc0(sizeof(*devc)))) {
- sr_err("Device context malloc failed.");
- return NULL;
- }
-
+ devc = g_malloc0(sizeof(struct dev_context));
sdi->priv = devc;
sdi->driver = di;
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("Brymen");
sdi->model = g_strdup("BM85x");
-
- if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_err("Device context malloc failed.");
- goto scan_cleanup;
- }
-
+ devc = g_malloc0(sizeof(struct dev_context));
sdi->inst_type = SR_INST_SERIAL;
sdi->conn = serial;
drvc = di->priv;
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("CEM");
sdi->model = g_strdup("DT-885x");
-
- if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_dbg("Device context malloc failed.");
- return NULL;
- }
+ devc = g_malloc0(sizeof(struct dev_context));
devc->cur_mqflags = 0;
devc->recording = -1;
devc->cur_meas_range = 0;
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(center_devs[idx].vendor);
sdi->model = g_strdup(center_devs[idx].device);
-
- if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_err("Device context malloc failed.");
- goto scan_cleanup;
- }
-
+ devc = g_malloc0(sizeof(struct dev_context));
sdi->inst_type = SR_INST_SERIAL;
sdi->conn = serial;
-
sdi->priv = devc;
sdi->driver = center_devs[idx].di;
drvc = di->priv;
/* Allocate memory for our private device context. */
- devc = g_try_malloc(sizeof(struct dev_context));
+ devc = g_malloc0(sizeof(struct dev_context));
/* Set some sane defaults. */
devc->prof = &cv_profiles[model];
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("Colead");
sdi->model = g_strdup("SL-5868P");
-
- if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_dbg("Device context malloc failed.");
- return NULL;
- }
-
+ devc = g_malloc0(sizeof(struct dev_context));
if (!(sdi->conn = sr_serial_dev_inst_new(conn, serialcomm)))
return NULL;
-
sdi->inst_type = SR_INST_SERIAL;
sdi->priv = devc;
sdi->driver = di;
sdi->vendor = g_strdup("Fluke");
sdi->model = g_strdup(tokens[0] + 6);
sdi->version = g_strdup(tokens[1] + s);
- if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_err("Device context malloc failed.");
- return NULL;
- }
+ devc = g_malloc0(sizeof(struct dev_context));
devc->profile = &supported_flukedmm[i];
sdi->inst_type = SR_INST_SERIAL;
sdi->conn = serial;
{
struct dev_context *devc;
- if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
- sr_err("Device context malloc failed.");
- return NULL;
- }
-
+ devc = g_malloc0(sizeof(struct dev_context));
devc->profile = NULL;
devc->fw_updated = 0;
devc->cur_samplerate = 0;
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(VENDOR_GMC);
sdi->model = g_strdup(gmc_model_str(model));
- if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_err("Device context malloc failed.");
- return NULL;
- }
+ devc = g_malloc0(sizeof(struct dev_context));
devc->model = model;
devc->limit_samples = 0;
devc->limit_msec = 0;
devc->num_samples = 0;
devc->elapsed_msec = g_timer_new();
devc->settings_ok = FALSE;
-
sdi->conn = serial;
sdi->priv = devc;
sdi->driver = &gmc_mh_1x_2x_rs232_driver_info;
if (serial_open(serial, SERIAL_RDWR) != SR_OK)
goto exit_err;
- if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_err("Device context malloc failed.");
- goto exit_err;
- }
+ devc = g_malloc0(sizeof(struct dev_context));
sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
- if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_err("Device context malloc failed.");
- goto exit_err;
- }
+ devc = g_malloc0(sizeof(struct dev_context));
sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sr_scpi_hw_info_free(hw_info);
hw_info = NULL;
- if (!(devc = g_try_malloc0(sizeof(struct dev_context))))
- goto fail;
+ devc = g_malloc0(sizeof(struct dev_context));
sdi->priv = devc;
continue;
}
- if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
- sr_err("Device instance malloc failed.");
- sr_usb_dev_inst_free(usb);
- continue;
- }
+ devc = g_malloc0(sizeof(struct dev_context));
if (!(devc->xfer_in = libusb_alloc_transfer(0))) {
sr_err("Transfer malloc failed.");
devices = NULL;
/* Allocate memory for our private device context. */
- if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_err("Device context malloc failed.");
- goto err_free_nothing;
- }
+ devc = g_malloc0(sizeof(struct dev_context));
/* Allocate memory for the incoming compressed samples. */
if (!(devc->compressed_buf = g_try_malloc0(COMPRESSED_BUF_SIZE))) {
g_free(devc->compressed_buf);
err_free_devc:
g_free(devc);
-err_free_nothing:
return NULL;
}
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "SPL")))
return NULL;
sdi->channels = g_slist_append(sdi->channels, ch);
-
- if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
- sr_dbg("Device context malloc failed.");
- return NULL;
- }
+ devc = g_malloc0(sizeof(struct dev_context));
sdi->priv = devc;
devc->limit_samples = 0;
/* The protocol provides no way to read the current
sdi->channels = g_slist_append(NULL, ch);
}
- if (!(devc = g_try_malloc0(sizeof(struct dev_context))))
- return NULL;
+ devc = g_malloc0(sizeof(struct dev_context));
sdi->priv = devc;
devc->profile = profile;
}
//Create the device context and set its params
struct dev_context *devc;
- if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_err("Device context malloc failed.");
- return devices;
- }
+ devc = g_malloc0(sizeof(struct dev_context));
if (mso_parse_serial(iSerial, iProduct, devc) != SR_OK) {
sr_err("Invalid iSerial: %s.", iSerial);
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(mic_devs[idx].vendor);
sdi->model = g_strdup(mic_devs[idx].device);
-
- if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_err("Device context malloc failed.");
- goto scan_cleanup;
- }
-
+ devc = g_malloc0(sizeof(struct dev_context));
sdi->inst_type = SR_INST_SERIAL;
sdi->conn = serial;
-
sdi->priv = devc;
sdi->driver = mic_devs[idx].di;
sdi->vendor = g_strdup(get_brandstr(drv));
sdi->model = g_strdup(get_typestr(auxtype, drv));
sdi->version = g_strdup(buf + 9);
- if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_err("Device context malloc failed.");
- return NULL;
- }
+ devc = g_malloc0(sizeof(struct dev_context));
devc->type = auxtype;
devc->version = g_strdup(&buf[9]);
devc->elapsed_msec = g_timer_new();
-
sdi->conn = serial;
sdi->priv = devc;
sdi->driver = drv;
{
struct dev_context *devc;
- if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
- sr_err("Device context malloc failed.");
- return NULL;
- }
+ devc = g_malloc0(sizeof(struct dev_context));
/* Device-specific settings */
devc->max_samples = devc->max_samplerate = devc->protocol_version = 0;
devices = NULL;
/* Allocate memory for our private device context. */
- if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_err("Device context malloc failed.");
- goto err_free_nothing;
- }
+ devc = g_malloc0(sizeof(struct dev_context));
/* Device-specific settings */
devc->max_samplebytes = devc->max_samplerate = devc->protocol_version = 0;
g_free(devc->ftdi_buf);
err_free_devc:
g_free(devc);
-err_free_nothing:
return NULL;
}
sdi->driver = di;
sdi->inst_type = SR_INST_SCPI;
sdi->serial_num = g_strdup(hw_info->serial_number);
-
- if (!(devc = g_try_malloc0(sizeof(struct dev_context))))
- return NULL;
-
+ devc = g_malloc0(sizeof(struct dev_context));
devc->limit_frames = 0;
devc->model = model;
devc->format = model->series->format;
sdi->channels = g_slist_append(sdi->channels, ch);
}
- if (!(devc = g_try_malloc0(sizeof(struct dev_context))))
- return NULL;
+ devc = g_malloc0(sizeof(struct dev_context));
devc->selected_voltage_range = VOLTAGE_RANGE_18_33_V;
sdi->priv = devc;
drvc->instances = g_slist_append(drvc->instances, sdi);
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(dmms[dmm].vendor);
sdi->model = g_strdup(dmms[dmm].device);
-
- if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_err("Device context malloc failed.");
- goto scan_cleanup;
- }
-
+ devc = g_malloc0(sizeof(struct dev_context));
sdi->inst_type = SR_INST_SERIAL;
sdi->conn = serial;
-
sdi->priv = devc;
sdi->driver = dmms[dmm].di;
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
struct dev_context *devc;
/* Allocate memory for our private driver context. */
- devc = g_try_new0(struct dev_context, 1);
- if (!devc) {
- sr_err("Device context malloc failed.");
- return NULL;
- }
+ devc = g_malloc0(sizeof(struct dev_context));
/* Register the device with libsigrok. */
sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("EDF");
sdi->model = g_strdup("Teleinfo");
-
- if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_err("Device context malloc failed.");
- goto scan_cleanup;
- }
-
+ devc = g_malloc0(sizeof(struct dev_context));
devc->optarif = teleinfo_get_optarif(buf);
-
sdi->inst_type = SR_INST_SERIAL;
sdi->conn = serial;
sdi->priv = devc;
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("Tondaj");
sdi->model = g_strdup("SL-814");
-
- if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_err("Device context malloc failed.");
- return NULL;
- }
+ devc = g_malloc0(sizeof(struct dev_context));
if (!(serial = sr_serial_dev_inst_new(conn, serialcomm)))
return NULL;
for (l = usb_devices; l; l = l->next) {
usb = l->data;
- if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_err("Device context malloc failed.");
- return NULL;
- }
+ devc = g_malloc0(sizeof(struct dev_context));
devc->first_run = TRUE;
}
sdi->channels = g_slist_append(sdi->channels, ch);
}
-
- if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
- sr_dbg("Device context malloc failed.");
- return NULL;
- }
+ devc = g_malloc0(sizeof(struct dev_context));
sdi->priv = devc;
devc->limit_samples = 0;
devc->data_source = DEFAULT_DATA_SOURCE;
sdi->vendor = g_strdup(VICTOR_VENDOR);
sdi->driver = di;
sdi->connection_id = g_strdup(connection_id);
-
- if (!(devc = g_try_malloc0(sizeof(struct dev_context))))
- return NULL;
+ devc = g_malloc0(sizeof(struct dev_context));
sdi->priv = devc;
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
sdi->connection_id = g_strdup(connection_id);
/* Allocate memory for our private driver context. */
- if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_err("Device context malloc failed.");
- return NULL;
- }
-
+ devc = g_malloc0(sizeof(struct dev_context));
sdi->priv = devc;
devc->prof = prof;
devc->num_channels = prof->channels;
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(vendor);
sdi->model = g_strdup(model);
-
- if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_err("Device context malloc failed.");
- goto scan_cleanup;
- }
+ devc = g_malloc0(sizeof(struct dev_context));
if (!(devc->buf = dev_buffer_new(PACKET_SIZE * 8)))
goto scan_cleanup;