# HG changeset patch # User reimar # Date 1390053540 0 # Node ID 8057935cd9e0a5715cf3ac405bf5f19ea5a3c281 # Parent 6e88ef2077a46a08c374b8eb71feec4cd705f06e vo_bl: Simplify realloc + memset to calloc. Also remove a condition that obviously cannot be true. diff -r 6e88ef2077a4 -r 8057935cd9e0 libvo/vo_bl.c --- a/libvo/vo_bl.c Sat Jan 18 13:55:52 2014 +0000 +++ b/libvo/vo_bl.c Sat Jan 18 13:59:00 2014 +0000 @@ -247,14 +247,14 @@ } /* resize or allocate frame and tmp buffers */ - ptr = realloc(bl_packet, bl_size); /* space for header and image data */ - if (!ptr) { + free(bl_packet); + bl_packet = calloc(bl_size, 1); /* space for header and image data */ + if (!bl_packet) { mp_msg(MSGT_VO, MSGL_ERR, "bl: out of memory error\n"); goto err_out; } - bl_packet = ptr; + image = ((unsigned char*)bl_packet + 12); /* pointer to image data */ - image = ((unsigned char*)bl_packet + 12); /* pointer to image data */ ptr = realloc(tmp, bl_size); /* space for image data only, could be slightly smaller */ if (!ptr) { mp_msg(MSGT_VO, MSGL_ERR, "bl: out of memory error\n"); @@ -281,11 +281,6 @@ mp_msg(MSGT_VO, MSGL_ERR, "bl: height of movie too large %d > %d\n", height, bl->height); goto err_out; } - if (!image) { - mp_msg(MSGT_VO, MSGL_ERR, "bl: image should be initialized, internal error\n"); - goto err_out; - } - memset(image, 0, bl_size - 12); /* blank the image */ mp_msg(MSGT_VO, MSGL_V, "vo_config bl called\n"); return 0; err_out: