blob: 896d22e382f122144f1d9da76519d9b77508fc9d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
/* See LICENSE file for copyright and license details. */
#include "common.h"
int
libgamepad_close_device(struct libgamepad_device *device)
{
int deferred_error = 0;
if (device) {
if (device->internals) {
deferred_error = device->internals->deferred_error;
if (device->internals->close_fd)
if (close(device->fd))
if (!deferred_error)
deferred_error = errno;
free(device->internals->absinfo);
free(device->internals->buttons);
free(device->internals->evbuf);
free(device->internals);
device->internals = NULL;
}
free(device->buttons);
free(device->absolute_axes);
free(device->relative_axes);
free(device->name);
free(device->unique_id);
free(device->physical_location);
device->buttons = NULL;
device->absolute_axes = NULL;
device->relative_axes = NULL;
device->name = NULL;
device->unique_id = NULL;
device->physical_location = NULL;
if (deferred_error) {
errno = deferred_error;
return -1;
}
}
return 0;
}
|