From: Uwe Hermann Date: Fri, 21 Nov 2014 01:01:36 +0000 (+0100) Subject: Eliminate sr_dev_inst_new(). X-Git-Tag: libsigrok-0.4.0~730 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=aac29cc192ccf82b64e77b5e6b11b411da32deed;p=libsigrok.git Eliminate sr_dev_inst_new(). --- diff --git a/src/device.c b/src/device.c index a45bd982..8367ec28 100644 --- a/src/device.c +++ b/src/device.c @@ -201,44 +201,23 @@ SR_API gboolean sr_dev_has_option(const struct sr_dev_inst *sdi, int key) 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); diff --git a/src/hardware/agilent-dmm/api.c b/src/hardware/agilent-dmm/api.c index edae4bd4..e8767a61 100644 --- a/src/hardware/agilent-dmm/api.c +++ b/src/hardware/agilent-dmm/api.c @@ -139,7 +139,7 @@ static GSList *scan(GSList *options) 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]); diff --git a/src/hardware/appa-55ii/api.c b/src/hardware/appa-55ii/api.c index a8c8a841..6598757b 100644 --- a/src/hardware/appa-55ii/api.c +++ b/src/hardware/appa-55ii/api.c @@ -99,7 +99,7 @@ static GSList *scan(GSList *options) 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"); diff --git a/src/hardware/asix-sigma/asix-sigma.c b/src/hardware/asix-sigma/asix-sigma.c index cad6b989..53e35816 100644 --- a/src/hardware/asix-sigma/asix-sigma.c +++ b/src/hardware/asix-sigma/asix-sigma.c @@ -380,7 +380,7 @@ static GSList *scan(GSList *options) 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); diff --git a/src/hardware/atten-pps3xxx/api.c b/src/hardware/atten-pps3xxx/api.c index b42036bf..580bc51d 100644 --- a/src/hardware/atten-pps3xxx/api.c +++ b/src/hardware/atten-pps3xxx/api.c @@ -164,7 +164,7 @@ static GSList *scan(GSList *options, int modelid) 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); diff --git a/src/hardware/beaglelogic/api.c b/src/hardware/beaglelogic/api.c index 910bb843..9a39e1de 100644 --- a/src/hardware/beaglelogic/api.c +++ b/src/hardware/beaglelogic/api.c @@ -97,7 +97,7 @@ static GSList *scan(GSList *options) 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"); diff --git a/src/hardware/brymen-bm86x/api.c b/src/hardware/brymen-bm86x/api.c index c38665c1..38c130d2 100644 --- a/src/hardware/brymen-bm86x/api.c +++ b/src/hardware/brymen-bm86x/api.c @@ -73,7 +73,7 @@ static GSList *scan(GSList *options) 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"); diff --git a/src/hardware/brymen-dmm/api.c b/src/hardware/brymen-dmm/api.c index 210d7e61..937135c6 100644 --- a/src/hardware/brymen-dmm/api.c +++ b/src/hardware/brymen-dmm/api.c @@ -75,7 +75,7 @@ static GSList *brymen_scan(const char *conn, const char *serialcomm) 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"); diff --git a/src/hardware/cem-dt-885x/api.c b/src/hardware/cem-dt-885x/api.c index 8d542542..c8ca2b8f 100644 --- a/src/hardware/cem-dt-885x/api.c +++ b/src/hardware/cem-dt-885x/api.c @@ -109,7 +109,7 @@ static GSList *scan(GSList *options) 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"); diff --git a/src/hardware/center-3xx/api.c b/src/hardware/center-3xx/api.c index d5801ce9..13831c05 100644 --- a/src/hardware/center-3xx/api.c +++ b/src/hardware/center-3xx/api.c @@ -88,7 +88,7 @@ static GSList *center_scan(const char *conn, const char *serialcomm, int idx) 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); diff --git a/src/hardware/chronovu-la/api.c b/src/hardware/chronovu-la/api.c index 3dc0598e..b31db039 100644 --- a/src/hardware/chronovu-la/api.c +++ b/src/hardware/chronovu-la/api.c @@ -120,7 +120,7 @@ static int add_device(int idx, int model, GSList **devices) 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); diff --git a/src/hardware/colead-slm/api.c b/src/hardware/colead-slm/api.c index fa941196..e879a102 100644 --- a/src/hardware/colead-slm/api.c +++ b/src/hardware/colead-slm/api.c @@ -82,7 +82,7 @@ static GSList *scan(GSList *options) 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"); diff --git a/src/hardware/conrad-digi-35-cpu/api.c b/src/hardware/conrad-digi-35-cpu/api.c index 8a9650ec..850e29b0 100644 --- a/src/hardware/conrad-digi-35-cpu/api.c +++ b/src/hardware/conrad-digi-35-cpu/api.c @@ -94,7 +94,7 @@ static GSList *scan(GSList *options) 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"); diff --git a/src/hardware/demo/demo.c b/src/hardware/demo/demo.c index 3d109c95..c93542ef 100644 --- a/src/hardware/demo/demo.c +++ b/src/hardware/demo/demo.c @@ -290,7 +290,7 @@ static GSList *scan(GSList *options) 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; diff --git a/src/hardware/fluke-dmm/api.c b/src/hardware/fluke-dmm/api.c index b7638fa2..a2208049 100644 --- a/src/hardware/fluke-dmm/api.c +++ b/src/hardware/fluke-dmm/api.c @@ -122,7 +122,7 @@ static GSList *fluke_scan(const char *conn, const char *serialcomm) 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); diff --git a/src/hardware/fx2lafw/api.c b/src/hardware/fx2lafw/api.c index 38ca70ff..64d3bfea 100644 --- a/src/hardware/fx2lafw/api.c +++ b/src/hardware/fx2lafw/api.c @@ -241,7 +241,7 @@ static GSList *scan(GSList *options) 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); diff --git a/src/hardware/gmc-mh-1x-2x/api.c b/src/hardware/gmc-mh-1x-2x/api.c index 464fe502..32a471af 100644 --- a/src/hardware/gmc-mh-1x-2x/api.c +++ b/src/hardware/gmc-mh-1x-2x/api.c @@ -223,7 +223,7 @@ static GSList *scan_1x_2x_rs232(GSList *options) 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)); @@ -304,7 +304,7 @@ static GSList *scan_2x_bd232(GSList *options) 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; @@ -355,7 +355,7 @@ static GSList *scan_2x_bd232(GSList *options) 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); } diff --git a/src/hardware/hameg-hmo/api.c b/src/hardware/hameg-hmo/api.c index b516b2d8..d8a0f902 100644 --- a/src/hardware/hameg-hmo/api.c +++ b/src/hardware/hameg-hmo/api.c @@ -79,7 +79,7 @@ static struct sr_dev_inst *hmo_probe_serial_device(struct sr_scpi_dev_inst *scpi 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); diff --git a/src/hardware/hantek-dso/api.c b/src/hardware/hantek-dso/api.c index 7bf0c529..efd36853 100644 --- a/src/hardware/hantek-dso/api.c +++ b/src/hardware/hantek-dso/api.c @@ -172,7 +172,7 @@ static struct sr_dev_inst *dso_dev_new(const struct dso_profile *prof) 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); diff --git a/src/hardware/ikalogic-scanalogic2/api.c b/src/hardware/ikalogic-scanalogic2/api.c index d459210f..380443c4 100644 --- a/src/hardware/ikalogic-scanalogic2/api.c +++ b/src/hardware/ikalogic-scanalogic2/api.c @@ -112,7 +112,7 @@ static GSList *scan(GSList *options) 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); diff --git a/src/hardware/ikalogic-scanaplus/api.c b/src/hardware/ikalogic-scanaplus/api.c index 50753646..d8165c7d 100644 --- a/src/hardware/ikalogic-scanaplus/api.c +++ b/src/hardware/ikalogic-scanaplus/api.c @@ -123,7 +123,7 @@ static GSList *scan(GSList *options) } /* 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); diff --git a/src/hardware/kecheng-kc-330b/api.c b/src/hardware/kecheng-kc-330b/api.c index 721ceda1..1e5480ac 100644 --- a/src/hardware/kecheng-kc-330b/api.c +++ b/src/hardware/kecheng-kc-330b/api.c @@ -129,7 +129,7 @@ static GSList *scan(GSList *options) 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. */ diff --git a/src/hardware/lascar-el-usb/protocol.c b/src/hardware/lascar-el-usb/protocol.c index ab5b6734..49ed649b 100644 --- a/src/hardware/lascar-el-usb/protocol.c +++ b/src/hardware/lascar-el-usb/protocol.c @@ -323,7 +323,7 @@ static struct sr_dev_inst *lascar_identify(unsigned char *config) 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); diff --git a/src/hardware/link-mso19/api.c b/src/hardware/link-mso19/api.c index 29a5952a..c1162c98 100644 --- a/src/hardware/link-mso19/api.c +++ b/src/hardware/link-mso19/api.c @@ -203,8 +203,11 @@ static GSList *scan(GSList *options) 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", diff --git a/src/hardware/manson-hcs-3xxx/api.c b/src/hardware/manson-hcs-3xxx/api.c index b04ab16f..d287067b 100644 --- a/src/hardware/manson-hcs-3xxx/api.c +++ b/src/hardware/manson-hcs-3xxx/api.c @@ -155,7 +155,7 @@ static GSList *scan(GSList *options) } /* 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); diff --git a/src/hardware/mic-985xx/api.c b/src/hardware/mic-985xx/api.c index d2ce842b..ae48fb6e 100644 --- a/src/hardware/mic-985xx/api.c +++ b/src/hardware/mic-985xx/api.c @@ -91,7 +91,7 @@ static GSList *mic_scan(const char *conn, const char *serialcomm, int idx) 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); diff --git a/src/hardware/motech-lps-30x/api.c b/src/hardware/motech-lps-30x/api.c index c2abb1fe..9c01ea45 100644 --- a/src/hardware/motech-lps-30x/api.c +++ b/src/hardware/motech-lps-30x/api.c @@ -450,7 +450,7 @@ static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *o 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); diff --git a/src/hardware/norma-dmm/api.c b/src/hardware/norma-dmm/api.c index ab9b36e2..2f56441a 100644 --- a/src/hardware/norma-dmm/api.c +++ b/src/hardware/norma-dmm/api.c @@ -144,7 +144,7 @@ static GSList *do_scan(struct sr_dev_driver* drv, GSList *options) 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)); diff --git a/src/hardware/openbench-logic-sniffer/api.c b/src/hardware/openbench-logic-sniffer/api.c index f5a66471..02cc02b5 100644 --- a/src/hardware/openbench-logic-sniffer/api.c +++ b/src/hardware/openbench-logic-sniffer/api.c @@ -180,7 +180,7 @@ static GSList *scan(GSList *options) } 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"); diff --git a/src/hardware/openbench-logic-sniffer/protocol.c b/src/hardware/openbench-logic-sniffer/protocol.c index c2b66615..c998c295 100644 --- a/src/hardware/openbench-logic-sniffer/protocol.c +++ b/src/hardware/openbench-logic-sniffer/protocol.c @@ -152,7 +152,7 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial) 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(); diff --git a/src/hardware/pipistrello-ols/protocol.c b/src/hardware/pipistrello-ols/protocol.c index 81bbe8e6..7eddec0d 100644 --- a/src/hardware/pipistrello-ols/protocol.c +++ b/src/hardware/pipistrello-ols/protocol.c @@ -226,7 +226,7 @@ SR_PRIV struct sr_dev_inst *p_ols_get_metadata(uint8_t *buf, int bytes_read, str 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; diff --git a/src/hardware/rigol-ds/api.c b/src/hardware/rigol-ds/api.c index 76327662..e1773997 100644 --- a/src/hardware/rigol-ds/api.c +++ b/src/hardware/rigol-ds/api.c @@ -296,7 +296,7 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) 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); diff --git a/src/hardware/saleae-logic16/api.c b/src/hardware/saleae-logic16/api.c index f151fbd9..c3aaacc5 100644 --- a/src/hardware/saleae-logic16/api.c +++ b/src/hardware/saleae-logic16/api.c @@ -198,7 +198,7 @@ static GSList *scan(GSList *options) 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"); diff --git a/src/hardware/scpi-pps/api.c b/src/hardware/scpi-pps/api.c index 2a7c80cc..c8070a06 100644 --- a/src/hardware/scpi-pps/api.c +++ b/src/hardware/scpi-pps/api.c @@ -89,7 +89,7 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) 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); diff --git a/src/hardware/serial-dmm/api.c b/src/hardware/serial-dmm/api.c index 87e63b10..2b300d4b 100644 --- a/src/hardware/serial-dmm/api.c +++ b/src/hardware/serial-dmm/api.c @@ -456,7 +456,7 @@ static GSList *sdmm_scan(const char *conn, const char *serialcomm, int dmm) 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); diff --git a/src/hardware/sysclk-lwla/api.c b/src/hardware/sysclk-lwla/api.c index f2fc1916..90d7897d 100644 --- a/src/hardware/sysclk-lwla/api.c +++ b/src/hardware/sysclk-lwla/api.c @@ -112,7 +112,7 @@ static struct sr_dev_inst *dev_inst_new(void) } /* 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); diff --git a/src/hardware/teleinfo/api.c b/src/hardware/teleinfo/api.c index 3e6a4d45..0f099c21 100644 --- a/src/hardware/teleinfo/api.c +++ b/src/hardware/teleinfo/api.c @@ -92,7 +92,7 @@ static GSList *scan(GSList *options) 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"); diff --git a/src/hardware/testo/api.c b/src/hardware/testo/api.c index 6f0e4e1a..58a5159f 100644 --- a/src/hardware/testo/api.c +++ b/src/hardware/testo/api.c @@ -124,7 +124,7 @@ static GSList *scan(GSList *options) 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"); diff --git a/src/hardware/tondaj-sl-814/api.c b/src/hardware/tondaj-sl-814/api.c index d725ec35..69aa30e9 100644 --- a/src/hardware/tondaj-sl-814/api.c +++ b/src/hardware/tondaj-sl-814/api.c @@ -84,7 +84,7 @@ static GSList *scan(GSList *options) 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"); diff --git a/src/hardware/uni-t-dmm/api.c b/src/hardware/uni-t-dmm/api.c index 35ceaaed..cf918510 100644 --- a/src/hardware/uni-t-dmm/api.c +++ b/src/hardware/uni-t-dmm/api.c @@ -260,7 +260,7 @@ static GSList *scan(GSList *options, int dmm) 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); diff --git a/src/hardware/uni-t-ut32x/api.c b/src/hardware/uni-t-ut32x/api.c index a50d4a4f..95096c0b 100644 --- a/src/hardware/uni-t-ut32x/api.c +++ b/src/hardware/uni-t-ut32x/api.c @@ -79,7 +79,7 @@ static GSList *scan(GSList *options) /* 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); diff --git a/src/hardware/victor-dmm/api.c b/src/hardware/victor-dmm/api.c index 9fb50837..65e73d8a 100644 --- a/src/hardware/victor-dmm/api.c +++ b/src/hardware/victor-dmm/api.c @@ -84,7 +84,7 @@ static GSList *scan(GSList *options) 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; diff --git a/src/hardware/yokogawa-dlm/api.c b/src/hardware/yokogawa-dlm/api.c index 28884de4..b4a1305b 100644 --- a/src/hardware/yokogawa-dlm/api.c +++ b/src/hardware/yokogawa-dlm/api.c @@ -67,7 +67,7 @@ static struct sr_dev_inst *probe_usbtmc_device(struct sr_scpi_dev_inst *scpi) 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); diff --git a/src/hardware/zeroplus-logic-cube/api.c b/src/hardware/zeroplus-logic-cube/api.c index 76ae1e33..b2e7b7f3 100644 --- a/src/hardware/zeroplus-logic-cube/api.c +++ b/src/hardware/zeroplus-logic-cube/api.c @@ -222,7 +222,7 @@ static GSList *scan(GSList *options) 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); diff --git a/src/input/binary.c b/src/input/binary.c index b3f12d76..5d5fc865 100644 --- a/src/input/binary.c +++ b/src/input/binary.c @@ -50,7 +50,7 @@ static int init(struct sr_input *in, GHashTable *options) 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")); diff --git a/src/input/chronovu_la8.c b/src/input/chronovu_la8.c index c1cf4d38..53fcd682 100644 --- a/src/input/chronovu_la8.c +++ b/src/input/chronovu_la8.c @@ -62,7 +62,7 @@ static int init(struct sr_input *in, GHashTable *options) 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")); diff --git a/src/input/csv.c b/src/input/csv.c index b2756fa0..68ab43b8 100644 --- a/src/input/csv.c +++ b/src/input/csv.c @@ -393,7 +393,7 @@ static int init(struct sr_input *in, GHashTable *options) 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")); diff --git a/src/input/vcd.c b/src/input/vcd.c index e6bc05e5..429dd616 100644 --- a/src/input/vcd.c +++ b/src/input/vcd.c @@ -429,7 +429,7 @@ static int init(struct sr_input *in, GHashTable *options) 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++) { diff --git a/src/input/wav.c b/src/input/wav.c index 8f8a3710..647b537c 100644 --- a/src/input/wav.c +++ b/src/input/wav.c @@ -150,7 +150,7 @@ static int init(struct sr_input *in, GHashTable *options) { (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; diff --git a/src/lcr/es51919.c b/src/lcr/es51919.c index 4cacbe9a..ecfcd0ed 100644 --- a/src/lcr/es51919.c +++ b/src/lcr/es51919.c @@ -843,7 +843,7 @@ SR_PRIV struct sr_dev_inst *es51919_serial_scan(GSList *options, 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); diff --git a/src/libsigrok-internal.h b/src/libsigrok-internal.h index bdbcb090..e61fb464 100644 --- a/src/libsigrok-internal.h +++ b/src/libsigrok-internal.h @@ -521,7 +521,6 @@ struct sr_dev_inst { }; /* 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 diff --git a/src/session_file.c b/src/session_file.c index 9f8ee756..6433998a 100644 --- a/src/session_file.c +++ b/src/session_file.c @@ -170,7 +170,7 @@ SR_API int sr_session_load(const char *filename, struct sr_session **session) 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) {