From ca02c0324118c918c0f968469f9ebff70827e612 Mon Sep 17 00:00:00 2001 From: Sebastian Zagrodzki Date: Sun, 9 Apr 2017 00:12:39 +0200 Subject: [PATCH] since this is the only usecase, return a *libusbDevice for a new pointer. --- usb/fakelibusb_test.go | 2 +- usb/libusb.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/usb/fakelibusb_test.go b/usb/fakelibusb_test.go index da58835..0cbfc00 100644 --- a/usb/fakelibusb_test.go +++ b/usb/fakelibusb_test.go @@ -306,7 +306,7 @@ func newFakeLibusb() *fakeLibusb { // without using the full USB stack. Since the fake library uses the // libusbDevice only as an identifier, use an arbitrary unique pointer. // The contents of these pointers is never accessed. - fl.fakeDevices[(*libusbDevice)(newCPointer())] = &fakeDevice{ + fl.fakeDevices[newDevicePointer()] = &fakeDevice{ desc: d, alt: 0, } diff --git a/usb/libusb.go b/usb/libusb.go index 355ce07..9e4da56 100644 --- a/usb/libusb.go +++ b/usb/libusb.go @@ -426,6 +426,6 @@ func libusbSetDebug(c *libusbContext, lvl int) { C.libusb_set_debug((*C.libusb_context)(c), C.int(lvl)) } -func newCPointer() unsafe.Pointer { - return unsafe.Pointer(C.malloc(1)) +func newDevicePointer() *libusbDevice { + return (*libusbDevice)(unsafe.Pointer(C.malloc(1))) }