[vlc-devel] [PATCH 1/2] wayland: use vlc_obj_calloc for sys
Rémi Denis-Courmont
remi at remlab.net
Thu Jan 31 10:59:17 CET 2019
Removing allocations looks like a step backward. It's not even correct for pointers.
Le 31 janvier 2019 11:57:02 GMT+02:00, Alexandre Janniaux <ajanni at videolabs.io> a écrit :
>---
> 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
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel
--
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20190131/f6b06d57/attachment.html>
More information about the vlc-devel
mailing list