diff --git a/usb_device_detection.c b/usb_device_detection.c index 762d622..f719d85 100644 --- a/usb_device_detection.c +++ b/usb_device_detection.c @@ -46,6 +46,8 @@ struct usb_detector* create_detector(uint16_t vendor_id, uint16_t product_id) struct usb_detector* detector = calloc(1, sizeof(struct usb_detector)); detector->usb_context = usb_context; + detector->is_connected = false; + detector->event_handler_should_exit = false; if (libusb_hotplug_register_callback(detector->usb_context, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | @@ -66,9 +68,6 @@ struct usb_detector* create_detector(uint16_t vendor_id, uint16_t product_id) return 0; } - detector->is_connected = false; - detector->event_handler_should_exit = false; - if (thrd_create(&detector->event_handler_thread, &libusb_event_handler, detector) != thrd_success) {