[vlc-devel] [PATCH 1/2] wayland: use vlc_obj_calloc for sys
Alexandre Janniaux
ajanni at videolabs.io
Thu Jan 31 10:57:02 CET 2019
---
modules/video_output/wayland/shm.c | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/modules/video_output/wayland/shm.c b/modules/video_output/wayland/shm.c
index 5616e6c6c1..b205be1c53 100644
--- a/modules/video_output/wayland/shm.c
+++ b/modules/video_output/wayland/shm.c
@@ -282,21 +282,14 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
if (cfg->window->type != VOUT_WINDOW_TYPE_WAYLAND)
return VLC_EGENERIC;
- vout_display_sys_t *sys = malloc(sizeof (*sys));
+ vout_display_sys_t *sys =
+ vd->sys = vlc_obj_calloc(VLC_OBJECT(vd), 1, sizeof (*sys));
+
if (unlikely(sys == NULL))
return VLC_ENOMEM;
- vd->sys = sys;
- sys->embed = NULL;
- sys->eventq = NULL;
- sys->shm = NULL;
- sys->viewporter = NULL;
- sys->active_buffers = 0;
- sys->x = 0;
- sys->y = 0;
sys->display_width = cfg->display.width;
sys->display_height = cfg->display.height;
- sys->use_buffer_transform = false;
/* Get window */
sys->embed = cfg->window;
@@ -326,8 +319,6 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
struct wl_surface *surface = sys->embed->handle.wl;
if (sys->viewporter != NULL)
sys->viewport = wp_viewporter_get_viewport(sys->viewporter, surface);
- else
- sys->viewport = NULL;
/* Determine our pixel format */
static const enum wl_output_transform transforms[8] = {
@@ -366,7 +357,6 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
error:
if (sys->eventq != NULL)
wl_event_queue_destroy(sys->eventq);
- free(sys);
return VLC_EGENERIC;
}
@@ -393,7 +383,6 @@ static void Close(vout_display_t *vd)
wl_shm_destroy(sys->shm);
wl_display_flush(display);
wl_event_queue_destroy(sys->eventq);
- free(sys);
}
vlc_module_begin()
--
2.20.1
More information about the vlc-devel
mailing list