mirror of https://github.com/nirenjan/libx52.git
parent
f2ee9707cb
commit
b7141a3e8b
|
@ -15,7 +15,7 @@
|
|||
#include <time.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef __cplusplus
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
@ -313,7 +313,7 @@ int libx52_update(libx52_device *x52);
|
|||
*/
|
||||
int libx52_vendor_command(libx52_device *x52, uint16_t index, uint16_t value);
|
||||
|
||||
#ifndef __cplusplus
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ libx52_device* libx52_init(void)
|
|||
libx52_device *x52_dev;
|
||||
|
||||
/* Allocate memory for the library's data structures */
|
||||
x52_dev = malloc(sizeof(libx52_device));
|
||||
x52_dev = calloc(1, sizeof(libx52_device));
|
||||
if (!x52_dev) {
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
|
@ -77,6 +77,11 @@ libx52_device* libx52_init(void)
|
|||
}
|
||||
libusb_free_device_list(list, 1);
|
||||
|
||||
/* Make sure we actually have an X52 device detected */
|
||||
if (!x52_dev->hdl) {
|
||||
goto err_recovery;
|
||||
}
|
||||
|
||||
return x52_dev;
|
||||
err_recovery:
|
||||
free(x52_dev);
|
||||
|
|
Loading…
Reference in New Issue