From bca4219dd0c8c1896a19ed5544b40656f5078b1b Mon Sep 17 00:00:00 2001 From: Bruno George de Moraes Date: Thu, 4 Sep 2014 20:44:51 -0300 Subject: malloc+memset(0) to calloc Signed-off-by: wm4 --- video/out/dither.c | 5 ++--- video/out/vo_x11.c | 6 ++---- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'video/out') diff --git a/video/out/dither.c b/video/out/dither.c index ac3e9f41d6..1fd458b48f 100644 --- a/video/out/dither.c +++ b/video/out/dither.c @@ -63,7 +63,6 @@ static void makegauss(struct ctx *k, unsigned int sizeb) { assert(sizeb >= 1 && sizeb <= MAX_SIZEB); - memset(k, 0, sizeof(*k)); av_lfg_init(&k->avlfg, 123); k->sizeb = sizeb; @@ -159,7 +158,7 @@ static void makeuniform(struct ctx *k) // out_matrix is a reactangular tsize * tsize array, where tsize = (1 << size). void mp_make_fruit_dither_matrix(float *out_matrix, int size) { - struct ctx *k = talloc(NULL, struct ctx); + struct ctx *k = talloc_zero(NULL, struct ctx); makegauss(k, size); makeuniform(k); float invscale = k->size2; @@ -225,7 +224,7 @@ static void print(struct ctx *k) int main(void) { mp_time_init(); - struct ctx *k = malloc(sizeof(struct ctx)); + struct ctx *k = calloc(1,sizeof(struct ctx)); int64_t s = mp_time_us(); makegauss(k, 6); makeuniform(k); diff --git a/video/out/vo_x11.c b/video/out/vo_x11.c index b3fd88d236..914522e6b8 100644 --- a/video/out/vo_x11.c +++ b/video/out/vo_x11.c @@ -212,12 +212,10 @@ shmemerror: p->myximage[foo] = XCreateImage(vo->x11->display, p->vinfo.visual, p->depth, ZPixmap, 0, NULL, p->image_width, p->image_height, 8, 0); - p->ImageDataOrig[foo] = - malloc(p->myximage[foo]->bytes_per_line * p->image_height + 32); + size_t sz = p->myximage[foo]->bytes_per_line * p->image_height + 32; + p->ImageDataOrig[foo] = calloc(1, sz); p->myximage[foo]->data = p->ImageDataOrig[foo] + 16 - ((long)p->ImageDataOrig & 15); - memset(p->myximage[foo]->data, 0, p->myximage[foo]->bytes_per_line - * p->image_height); p->ImageData[foo] = p->myximage[foo]->data; #if HAVE_SHM && HAVE_XEXT } -- cgit v1.2.3