summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno George de Moraes <bruno.gm0@gmail.com>2014-09-04 20:44:51 -0300
committerwm4 <wm4@nowhere>2014-09-05 01:59:11 +0200
commitbca4219dd0c8c1896a19ed5544b40656f5078b1b (patch)
treed01865e2652ca101d6691cb75cae0542f2485bb0
parenta7d737a6986446ba921690cc985468534ed8caab (diff)
downloadmpv-bca4219dd0c8c1896a19ed5544b40656f5078b1b.tar.bz2
mpv-bca4219dd0c8c1896a19ed5544b40656f5078b1b.tar.xz
malloc+memset(0) to calloc
Signed-off-by: wm4 <wm4@nowhere>
-rw-r--r--TOOLS/vf_dlopen/framestep.c3
-rw-r--r--TOOLS/vf_dlopen/ildetect.c3
-rw-r--r--TOOLS/vf_dlopen/rectangle.c3
-rw-r--r--TOOLS/vf_dlopen/telecine.c3
-rw-r--r--TOOLS/vf_dlopen/tile.c3
-rw-r--r--video/out/dither.c5
-rw-r--r--video/out/vo_x11.c6
7 files changed, 9 insertions, 17 deletions
diff --git a/TOOLS/vf_dlopen/framestep.c b/TOOLS/vf_dlopen/framestep.c
index 4e25f295ca..11c5afe349 100644
--- a/TOOLS/vf_dlopen/framestep.c
+++ b/TOOLS/vf_dlopen/framestep.c
@@ -90,8 +90,7 @@ int vf_dlopen_getcontext(struct vf_dlopen_context *ctx, int argc, const char **a
if (argc != 1 && argc != 2)
return -1;
- framestep_data_t *framestep = malloc(sizeof(framestep_data_t));
- memset(framestep, 0, sizeof(*framestep));
+ framestep_data_t *framestep = calloc(1,sizeof(framestep_data_t));
framestep->step = atoi(argv[0]);
framestep->pos = (argc >= 2) ? atoi(argv[1]) : 0;
diff --git a/TOOLS/vf_dlopen/ildetect.c b/TOOLS/vf_dlopen/ildetect.c
index ef4e45f013..d2f3d5bde5 100644
--- a/TOOLS/vf_dlopen/ildetect.c
+++ b/TOOLS/vf_dlopen/ildetect.c
@@ -267,8 +267,7 @@ int vf_dlopen_getcontext(struct vf_dlopen_context *ctx, int argc, const char **a
(void) argc;
(void) argv;
- ildetect_data_t *il = malloc(sizeof(ildetect_data_t));
- memset(il, 0, sizeof(*il));
+ ildetect_data_t *il = calloc(1,sizeof(ildetect_data_t));
#define A(i,d) ((argc>(i) && *argv[i]) ? atof(argv[i]) : (d))
il->method = A(0, 0);
diff --git a/TOOLS/vf_dlopen/rectangle.c b/TOOLS/vf_dlopen/rectangle.c
index 0aaa360598..f0827c974b 100644
--- a/TOOLS/vf_dlopen/rectangle.c
+++ b/TOOLS/vf_dlopen/rectangle.c
@@ -348,8 +348,7 @@ int vf_dlopen_getcontext(struct vf_dlopen_context *ctx, int argc, const char **a
{ "yuv420p", "yuv420p" },
{ NULL, NULL }
};
- privdata *priv = malloc(sizeof(privdata));
- memset(priv, 0, sizeof(*priv));
+ privdata *priv = calloc(1,sizeof(privdata));
priv->step = 8;
if(argc >= 1)
priv->w = atoi(argv[0]);
diff --git a/TOOLS/vf_dlopen/telecine.c b/TOOLS/vf_dlopen/telecine.c
index b2ad303119..6c5eb4adc0 100644
--- a/TOOLS/vf_dlopen/telecine.c
+++ b/TOOLS/vf_dlopen/telecine.c
@@ -237,8 +237,7 @@ int vf_dlopen_getcontext(struct vf_dlopen_context *ctx, int argc, const char **a
if (!a0[0] || a0[1] || !a1[0] || argc > 2)
return -1;
- tc_data_t *tc = malloc(sizeof(tc_data_t));
- memset(tc, 0, sizeof(*tc));
+ tc_data_t *tc = calloc(1,sizeof(tc_data_t));
if (a0[0] == 't')
tc->firstfield = 0;
diff --git a/TOOLS/vf_dlopen/tile.c b/TOOLS/vf_dlopen/tile.c
index 57355bbc4c..bf5aeea26f 100644
--- a/TOOLS/vf_dlopen/tile.c
+++ b/TOOLS/vf_dlopen/tile.c
@@ -150,8 +150,7 @@ int vf_dlopen_getcontext(struct vf_dlopen_context *ctx, int argc, const char **a
if (argc != 2)
return -1;
- tile_data_t *tile = malloc(sizeof(tile_data_t));
- memset(tile, 0, sizeof(*tile));
+ tile_data_t *tile = calloc(1,sizeof(tile_data_t));
tile->cols = atoi(argv[0]);
tile->rows = atoi(argv[1]);
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
}