return ret;
}
-/** @private
- * Allocate and init a new device instance struct.
- *
- * @retval struct sr_dev_inst *. Dynamically allocated, free using
- * sr_dev_inst_free().
- */
-SR_PRIV struct sr_dev_inst *sr_dev_inst_new(void)
-{
- struct sr_dev_inst *sdi;
-
- sdi = g_malloc0(sizeof(struct sr_dev_inst));
-
- sdi->driver = NULL;
- sdi->status = -1;
- sdi->inst_type = -1;
- sdi->vendor = NULL;
- sdi->model = NULL;
- sdi->version = NULL;
- sdi->serial_num = NULL;
- sdi->connection_id = NULL;
- sdi->channels = NULL;
- sdi->channel_groups = NULL;
- sdi->session = NULL;
- sdi->conn = NULL;
- sdi->priv = NULL;
-
- return sdi;
-}
-
/**
* Allocate and init a new user-generated device instance.
+ *
+ * @param vendor Device vendor
+ * @param model Device model
+ * @param version Device version
+ *
+ * @retval struct sr_dev_inst *. Dynamically allocated, free using
+ * sr_dev_inst_free().
*/
SR_API struct sr_dev_inst *sr_dev_inst_user_new(const char *vendor,
const char *model, const char *version)
{
struct sr_dev_inst *sdi;
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
+
sdi->vendor = g_strdup(vendor);
sdi->model = g_strdup(model);
sdi->version = g_strdup(version);
for (i = 0; supported_agdmm[i].model; i++) {
if (strcmp(supported_agdmm[i].modelname, tokens[1]))
continue;
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("Agilent");
sdi->model = g_strdup(tokens[1]);
sr_info("Found device on port %s.", conn);
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("APPA");
sdi->model = g_strdup("55II");
devc->use_triggers = 0;
/* Register SIGMA device. */
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INITIALIZING;
sdi->vendor = g_strdup(USB_VENDOR_NAME);
sdi->model = g_strdup(USB_MODEL_NAME);
return NULL;
}
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("Atten");
sdi->model = g_strdup(model->name);
if (!g_file_test(BEAGLELOGIC_DEV_NODE, G_FILE_TEST_EXISTS))
return NULL;
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->model = g_strdup("BeagleLogic");
sdi->version = g_strdup("1.0");
for (l = usb_devices; l; l = l->next) {
usb = l->data;
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("Brymen");
sdi->model = g_strdup("BM869");
sr_info("Found device on port %s.", conn);
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("Brymen");
sdi->model = g_strdup("BM85x");
while (g_get_monotonic_time() - start < MAX_SCAN_TIME) {
if (serial_read_nonblocking(serial, &c, 1) == 1 && c == 0xa5) {
/* Found one. */
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("CEM");
sdi->model = g_strdup("DT-885x");
sr_info("Found device on port %s.", conn);
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(center_devs[idx].vendor);
sdi->model = g_strdup(center_devs[idx].device);
devc->cur_samplerate = devc->prof->max_samplerate;
/* Register the device with libsigrok. */
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INITIALIZING;
sdi->vendor = g_strdup("ChronoVu");
sdi->model = g_strdup(devc->prof->modelname);
if (!serialcomm)
serialcomm = SERIALCOMM;
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("Colead");
sdi->model = g_strdup("SL-5868P");
sr_spew("Conrad DIGI 35 CPU assumed at %s.", conn);
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_ACTIVE;
sdi->vendor = g_strdup("Conrad");
sdi->model = g_strdup("DIGI 35 CPU");
devices = NULL;
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_ACTIVE;
sdi->model = g_strdup("Demo device");
sdi->driver = di;
continue;
/* Skip leading spaces in version number. */
for (s = 0; tokens[1][s] == ' '; s++);
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("Fluke");
sdi->model = g_strdup(tokens[0] + 6);
if (!prof)
continue;
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INITIALIZING;
sdi->vendor = g_strdup(prof->vendor);
sdi->model = g_strdup(prof->model);
if (model != METRAHIT_NONE) {
sr_spew("%s %s detected!", VENDOR_GMC, gmc_model_str(model));
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(VENDOR_GMC);
sdi->model = g_strdup(gmc_model_str(model));
goto exit_err;
}
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(VENDOR_GMC);
sdi->priv = devc;
goto exit_err;
}
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(VENDOR_GMC);
}
if (check_manufacturer(hw_info->manufacturer) != SR_OK)
goto fail;
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_ACTIVE;
sdi->vendor = g_strdup(hw_info->manufacturer);
sdi->model = g_strdup(hw_info->model);
struct dev_context *devc;
int i;
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INITIALIZING;
sdi->vendor = g_strdup(prof->vendor);
sdi->model = g_strdup(prof->model);
continue;
}
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(VENDOR_NAME);
sdi->model = g_strdup(MODEL_NAME);
}
/* Register the device with libsigrok. */
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INITIALIZING;
sdi->vendor = g_strdup(USB_VENDOR_NAME);
sdi->model = g_strdup(USB_MODEL_NAME);
for (l = usb_devices; l; l = l->next) {
if (scan_kecheng(l->data, &model) != SR_OK)
continue;
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(VENDOR);
sdi->model = model; /* Already g_strndup()'d. */
return NULL;
}
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(LASCAR_VENDOR);
sdi->model = g_strdup(profile->modelname);
return devices;
}
- struct sr_dev_inst *sdi = sr_dev_inst_new(SR_ST_INACTIVE,
- manufacturer, product, hwrev);
+ struct sr_dev_inst *sdi = g_malloc0(sizeof(struct sr_dev_inst));
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup(manufacturer);
+ sdi->model = g_strdup(product);
+ sdi->version = g_strdup(hwrev);
if (!sdi) {
sr_err("Unable to create device instance for %s",
}
/* Init device instance, etc. */
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("Manson");
sdi->model = g_strdup(models[model_id].name);
sr_info("Found device on port %s.", conn);
/* TODO: Fill in version from protocol response. */
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(mic_devs[idx].vendor);
sdi->model = g_strdup(mic_devs[idx].device);
Therefore just print an error message, but do not exit with error. */
sr_err("Failed to query for hardware version: %d %s", errno, strerror(errno));
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(VENDOR_MOTECH);
sdi->model = g_strdup(models[modelid].modelstr);
auxtype = xgittoint(buf[7]);
sr_spew("%s %s DMM %s detected!", get_brandstr(drv), get_typestr(auxtype, drv), buf + 9);
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(get_brandstr(drv));
sdi->model = g_strdup(get_typestr(auxtype, drv));
} else {
/* Not an OLS -- some other board that uses the sump protocol. */
sr_info("Device does not support metadata.");
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("Sump");
sdi->model = g_strdup("Logic Analyzer");
GString *tmp_str, *devname, *version;
guchar tmp_c;
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->driver = di;
devc = ols_dev_new();
guchar tmp_c;
int index, i;
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->driver = di;
sdi->priv = devc;
return NULL;
}
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_ACTIVE;
sdi->vendor = g_strdup(model->series->vendor->name);
sdi->model = g_strdup(model->name);
if (des.idVendor != LOGIC16_VID || des.idProduct != LOGIC16_PID)
continue;
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INITIALIZING;
sdi->vendor = g_strdup("Saleae");
sdi->model = g_strdup("Logic16");
return NULL;
}
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_ACTIVE;
sdi->vendor = g_strdup(vendor);
sdi->model = g_strdup(hw_info->model);
sr_info("Found device on port %s.", conn);
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(dmms[dmm].vendor);
sdi->model = g_strdup(dmms[dmm].device);
}
/* Register the device with libsigrok. */
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(VENDOR_NAME);
sdi->model = g_strdup(MODEL_NAME);
sr_info("Found device on port %s.", conn);
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("EDF");
sdi->model = g_strdup("Teleinfo");
if (strcmp(product, "testo 435/635/735"))
continue;
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("Testo");
sdi->model = g_strdup("435/635/735");
if (!serialcomm)
serialcomm = SERIALCOMM;
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("Tondaj");
sdi->model = g_strdup("SL-814");
devc->first_run = TRUE;
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(udmms[dmm].vendor);
sdi->model = g_strdup(udmms[dmm].device);
/* We have a list of sr_usb_dev_inst matching the connection
* string. Wrap them in sr_dev_inst and we're done. */
for (l = usb_devices; l; l = l->next) {
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(VENDOR);
sdi->model = g_strdup(MODEL);
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(VICTOR_VENDOR);
sdi->driver = di;
if (dlm_model_get(hw_info->model, &model_name, &model_index) != SR_OK)
goto fail;
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_ACTIVE;
sdi->vendor = g_strdup(MANUFACTURER_NAME);
sdi->model = g_strdup(model_name);
sr_info("Found ZEROPLUS %s.", prof->model_name);
/* Register the device with libsigrok. */
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(VENDOR_NAME);
sdi->model = g_strdup(prof->model_name);
return SR_ERR_ARG;
}
- in->sdi = sr_dev_inst_new();
+ in->sdi = g_malloc0(sizeof(struct sr_dev_inst));
in->priv = inc = g_malloc0(sizeof(struct context));
inc->samplerate = g_variant_get_uint64(g_hash_table_lookup(options, "samplerate"));
return SR_ERR_ARG;
}
- in->sdi = sr_dev_inst_new();
+ in->sdi = g_malloc0(sizeof(struct sr_dev_inst));
in->priv = inc = g_malloc0(sizeof(struct context));
inc->samplerate = g_variant_get_uint64(g_hash_table_lookup(options, "samplerate"));
struct context *inc;
const char *s;
- in->sdi = sr_dev_inst_new();
+ in->sdi = g_malloc0(sizeof(struct sr_dev_inst));
in->priv = inc = g_malloc0(sizeof(struct context));
inc->single_column = g_variant_get_int32(g_hash_table_lookup(options, "single-column"));
inc->skip = g_variant_get_int32(g_hash_table_lookup(options, "skip"));
inc->skip /= inc->downsample;
- in->sdi = sr_dev_inst_new();
+ in->sdi = g_malloc0(sizeof(struct sr_dev_inst));
in->priv = inc;
for (i = 0; i < num_channels; i++) {
{
(void)options;
- in->sdi = sr_dev_inst_new();
+ in->sdi = g_malloc0(sizeof(struct sr_dev_inst));
in->priv = g_malloc0(sizeof(struct context));
return SR_OK;
sr_info("Found device on port %s.", serial->port);
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(vendor);
sdi->model = g_strdup(model);
};
/* Generic device instances */
-SR_PRIV struct sr_dev_inst *sr_dev_inst_new(void);
SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi);
#ifdef HAVE_LIBUSB_1_0
for (j = 0; keys[j]; j++) {
val = g_key_file_get_string(kf, sections[i], keys[j], NULL);
if (!strcmp(keys[j], "capturefile")) {
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->driver = &session_driver;
sdi->status = SR_ST_ACTIVE;
if (!session_driver_initialized) {