mirror of
				https://gitlab.freedesktop.org/wayland/wayland.git
				synced 2025-11-03 09:01:42 -05:00 
			
		
		
		
	server: add wl_input_device_release()
Add a clean-up function for destroying all objects created in wl_input_device_init(). Can be used to fix memory leaks reported by Valgrind in the demos. The init function was also missing an explicit initialisation of the 'keys' array. Add the explicit array init, although it is redundant with the zeroing of the whole struct. Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com> krh: Edited to rename function to *_release()
This commit is contained in:
		
							parent
							
								
									d6465c5b40
								
							
						
					
					
						commit
						2755847fce
					
				
					 2 changed files with 18 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -411,6 +411,7 @@ wl_input_device_init(struct wl_input_device *device)
 | 
			
		|||
{
 | 
			
		||||
	memset(device, 0, sizeof *device);
 | 
			
		||||
	wl_list_init(&device->resource_list);
 | 
			
		||||
	wl_array_init(&device->keys);
 | 
			
		||||
	device->pointer_focus_listener.func = lose_pointer_focus;
 | 
			
		||||
	device->keyboard_focus_listener.func = lose_keyboard_focus;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -418,6 +419,20 @@ wl_input_device_init(struct wl_input_device *device)
 | 
			
		|||
	device->y = 100;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
WL_EXPORT void
 | 
			
		||||
wl_input_device_release(struct wl_input_device *device)
 | 
			
		||||
{
 | 
			
		||||
	if (device->keyboard_focus_resource)
 | 
			
		||||
		wl_list_remove(&device->keyboard_focus_listener.link);
 | 
			
		||||
 | 
			
		||||
	if (device->pointer_focus_resource)
 | 
			
		||||
		wl_list_remove(&device->pointer_focus_listener.link);
 | 
			
		||||
 | 
			
		||||
	/* XXX: What about device->resource_list? */
 | 
			
		||||
 | 
			
		||||
	wl_array_release(&device->keys);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static struct wl_resource *
 | 
			
		||||
find_resource_for_surface(struct wl_list *list, struct wl_surface *surface)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue