From 60e0504077c1e0d7b49ce1ef554703867b0107d5 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 19 Apr 2014 02:17:34 -0400 Subject: [PATCH] Fixed some issues reported on new Ubuntu 14.04 buildbots. --- src/video/wayland/SDL_waylandmouse.c | 13 ++++++------- src/video/wayland/SDL_waylandtouch.c | 9 ++++++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/video/wayland/SDL_waylandmouse.c b/src/video/wayland/SDL_waylandmouse.c index 2590b4923f01d..74a9f9b733030 100644 --- a/src/video/wayland/SDL_waylandmouse.c +++ b/src/video/wayland/SDL_waylandmouse.c @@ -106,6 +106,7 @@ create_buffer_from_shm(Wayland_CursorData *d, { SDL_VideoDevice *vd = SDL_GetVideoDevice(); SDL_VideoData *data = (SDL_VideoData *) vd->driverdata; + struct wl_shm_pool *shm_pool; int stride = width * 4; int size = stride * height; @@ -131,9 +132,7 @@ create_buffer_from_shm(Wayland_CursorData *d, close (shm_fd); } - struct wl_shm_pool *shm_pool = wl_shm_create_pool(data->shm, - shm_fd, - size); + shm_pool = wl_shm_create_pool(data->shm, shm_fd, size); d->buffer = wl_shm_pool_create_buffer(shm_pool, 0, width, @@ -280,18 +279,18 @@ Wayland_CreateSystemCursor(SDL_SystemCursor id) break; } - SDL_Cursor *sdl_cursor = CreateCursorFromWlCursor (d, cursor); - - return sdl_cursor; + return CreateCursorFromWlCursor(d, cursor); } static void Wayland_FreeCursor(SDL_Cursor *cursor) { + Wayland_CursorData *d; + if (!cursor) return; - Wayland_CursorData *d = cursor->driverdata; + d = cursor->driverdata; /* Probably not a cursor we own */ if (!d) diff --git a/src/video/wayland/SDL_waylandtouch.c b/src/video/wayland/SDL_waylandtouch.c index 683c7029fc71a..0daec4dc4ee2c 100644 --- a/src/video/wayland/SDL_waylandtouch.c +++ b/src/video/wayland/SDL_waylandtouch.c @@ -236,13 +236,16 @@ WL_EXPORT const struct wl_interface qt_extended_surface_interface = { void Wayland_touch_create(SDL_VideoData *data, uint32_t id) { + struct SDL_WaylandTouch *touch; + if (data->touch) { Wayland_touch_destroy(data); } - data->touch = malloc(sizeof(struct SDL_WaylandTouch)); + /* !!! FIXME: check for failure, call SDL_OutOfMemory() */ + data->touch = SDL_malloc(sizeof(struct SDL_WaylandTouch)); - struct SDL_WaylandTouch *touch = data->touch; + touch = data->touch; touch->touch_extension = wl_registry_bind(data->registry, id, &qt_touch_extension_interface, 1); qt_touch_extension_add_listener(touch->touch_extension, &touch_listener, data); } @@ -256,7 +259,7 @@ Wayland_touch_destroy(SDL_VideoData *data) qt_touch_extension_destroy(touch->touch_extension); } - free(data->touch); + SDL_free(data->touch); data->touch = NULL; } }