Gamepad / Mouse / Keyboard (FreeBSD): fix memleaks

This commit is contained in:
李通洲
2025-03-27 10:59:29 +08:00
parent e73647973d
commit 3fb773eedd
2 changed files with 4 additions and 2 deletions
+1
View File
@@ -53,6 +53,7 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */)
device->battery = 0;
}
}
hid_end_parse(hData);
}
hid_dispose_report_desc(repDesc);
+3 -2
View File
@@ -11,12 +11,12 @@
#include <bus/u4b/usb_ioctl.h> // DragonFly
#endif
#define MAX_UHID_JOYS 64
#define MAX_UHID_MICE 64
const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */)
{
char path[16];
for (int i = 0; i < MAX_UHID_JOYS; i++)
for (int i = 0; i < MAX_UHID_MICE; i++)
{
snprintf(path, ARRAY_SIZE(path), "/dev/uhid%d", i);
FF_AUTO_CLOSE_FD int fd = open(path, O_RDONLY | O_CLOEXEC);
@@ -43,6 +43,7 @@ const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */)
ffStrbufInitS(&device->name, di.udi_product);
}
}
hid_end_parse(hData);
}
hid_dispose_report_desc(repDesc);