aboutsummaryrefslogblamecommitdiffstats
path: root/libgamepad_close_device.c
blob: 273c7f8649fc5dfcdb297023f0f26f7177d41806 (plain) (tree)
1
2
3
4
5
6
7
8







                                                         




                                                                      

                                                         


                                                 


                                            


                                                


                                             


                                                 

         
/* See LICENSE file for copyright and license details. */
#include "common.h"


void
libgamepad_close_device(struct libgamepad_device *device)
{
	if (device) {
		if (device->internals) {
			if (device->internals->close_fd)
				close(device->fd);
			if (device->internals->dev)
				libevdev_free(device->internals->dev);
			free(device->internals->absinfo);
			free(device->internals->buttons);
			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;
	}
}