From 1ebfddd812230d641d934d312646638dd7091ba9 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Sun, 20 Apr 2008 06:04:10 +0300 Subject: Allocate vo struct with talloc Also allocate the private vo_xv struct as a child and remove explicit free() for it. --- libvo/video_out.c | 5 +++-- libvo/vo_xv.c | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libvo/video_out.c b/libvo/video_out.c index bb1e29d0c9..abbaaae7ef 100644 --- a/libvo/video_out.c +++ b/libvo/video_out.c @@ -11,6 +11,7 @@ #include "config.h" #include "options.h" +#include "talloc.h" #include "video_out.h" #include "aspect.h" #include "geometry.h" @@ -282,7 +283,7 @@ void vo_check_events(struct vo *vo) void vo_destroy(struct vo *vo) { vo->driver->uninit(vo); - free(vo); + talloc_free(vo); } void list_video_out(void) @@ -301,7 +302,7 @@ struct vo *init_best_video_out(struct MPOpts *opts) { char **vo_list = opts->video_driver_list; int i; - struct vo *vo = malloc(sizeof *vo); + struct vo *vo = talloc_ptrtype(NULL, vo); // first try the preferred drivers, with their optional subdevice param: if (vo_list && vo_list[0]) while (vo_list[0][0]) { diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c index 15aef38f63..eebfb66f89 100644 --- a/libvo/vo_xv.c +++ b/libvo/vo_xv.c @@ -23,6 +23,7 @@ Buffer allocation: #include "config.h" #include "options.h" +#include "talloc.h" #include "mp_msg.h" #include "help_mp.h" #include "video_out.h" @@ -707,8 +708,6 @@ static void uninit(struct vo *vo) mp_input_rm_event_fd(ConnectionNumber(mDisplay)); // uninit() shouldn't get called unless initialization went past vo_init() vo_x11_uninit(); - free(ctx); - vo->priv = NULL; } static void x11_fd_callback(void *ctx) @@ -723,7 +722,7 @@ static int preinit(struct vo *vo, const char *arg) unsigned int i; strarg_t ck_src_arg = { 0, NULL }; strarg_t ck_method_arg = { 0, NULL }; - struct xvctx *ctx = calloc(1, sizeof *ctx); + struct xvctx *ctx = talloc_zero(vo, struct xvctx); vo->priv = ctx; opt_t subopts[] = -- cgit v1.2.3