Use zalloc rather than malloc and manually setting members to 0
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
diff --git a/src/screenshooter.c b/src/screenshooter.c
index cafbf10..6246cda 100644
--- a/src/screenshooter.c
+++ b/src/screenshooter.c
@@ -481,7 +481,7 @@
do_yflip = !!(compositor->capabilities & WESTON_CAP_CAPTURE_YFLIP);
- recorder = malloc(sizeof *recorder);
+ recorder = zalloc(sizeof *recorder);
if (recorder == NULL) {
weston_log("%s: out of memory\n", __func__);
return;
@@ -491,9 +491,6 @@
size = stride * 4 * output->current_mode->height;
recorder->frame = zalloc(size);
recorder->rect = malloc(size);
- recorder->total = 0;
- recorder->count = 0;
- recorder->destroying = 0;
recorder->output = output;
if ((recorder->frame == NULL) || (recorder->rect == NULL)) {
@@ -502,9 +499,7 @@
return;
}
- if (do_yflip)
- recorder->tmpbuf = NULL;
- else
+ if (!do_yflip)
recorder->tmpbuf = malloc(size);
header.magic = WCAP_HEADER_MAGIC;