Display and control your Android device
Add move-function for sc_usb_device
Romain Vimontb88c4aa75e73
diff --git a/app/src/usb/usb.c b/app/src/usb/usb.cindex d705f647..cc9c78cc 100644--- a/app/src/usb/usb.c+++ b/app/src/usb/usb.c@@ -72,12 +72,23 @@ accept_device(libusb_device *device, const char *serial,voidsc_usb_device_destroy(struct sc_usb_device *usb_device) {- libusb_unref_device(usb_device->device);+ if (usb_device->device) {+ libusb_unref_device(usb_device->device);+ }free(usb_device->serial);free(usb_device->manufacturer);free(usb_device->product);}+void+sc_usb_device_move(struct sc_usb_device *dst, struct sc_usb_device *src) {+ *dst = *src;+ src->device = NULL;+ src->serial = NULL;+ src->manufacturer = NULL;+ src->product = NULL;+}+voidsc_usb_devices_destroy_all(struct sc_usb_device *usb_devices, size_t count) {for (size_t i = 0; i < count; ++i) {diff --git a/app/src/usb/usb.h b/app/src/usb/usb.hindex a8810b90..bed41cd6 100644--- a/app/src/usb/usb.h+++ b/app/src/usb/usb.h@@ -40,6 +40,18 @@ struct sc_usb_device {voidsc_usb_device_destroy(struct sc_usb_device *usb_device);+/**+ * Move src to dst+ *+ * After this call, the content of src is undefined, except that+ * sc_usb_device_destroy() can be called.+ *+ * This is useful to take a device from a list that will be destroyed, without+ * making unnecessary copies.+ */+void+sc_usb_device_move(struct sc_usb_device *dst, struct sc_usb_device *src);+voidsc_usb_devices_destroy_all(struct sc_usb_device *usb_devices, size_t count);