replace malloc() with ecalloc()

This commit is contained in:
Markus Teich 2016-11-04 19:50:09 +01:00
parent ca7978c59b
commit 0ff43aaf34

14
sent.c
View File

@ -217,14 +217,11 @@ ffload(Slide *s)
if (s->img->buf) if (s->img->buf)
free(s->img->buf); free(s->img->buf);
/* internally the image is stored in 888 format */ /* internally the image is stored in 888 format */
if (!(s->img->buf = malloc(3 * s->img->bufwidth * s->img->bufheight))) s->img->buf = ecalloc(s->img->bufwidth * s->img->bufheight, strlen("888"));
die("sent: Unable to allocate buffer for image:");
/* scratch buffer to read row by row */ /* scratch buffer to read row by row */
rowlen = s->img->bufwidth * 2 * strlen("RGBA"); rowlen = s->img->bufwidth * 2 * strlen("RGBA");
row = malloc(rowlen); row = ecalloc(1, rowlen);
if (!row)
die("sent: Unable to allocate buffer for image row:");
/* extract window background color channels for transparency */ /* extract window background color channels for transparency */
bg_r = (sc[ColBg].pixel >> 16) % 256; bg_r = (sc[ColBg].pixel >> 16) % 256;
@ -275,9 +272,7 @@ ffprepare(Image *img)
NULL, width, height, 32, 0))) NULL, width, height, 32, 0)))
die("sent: Unable to create XImage"); die("sent: Unable to create XImage");
if (!(img->ximg->data = malloc(img->ximg->bytes_per_line * height))) img->ximg->data = ecalloc(height, img->ximg->bytes_per_line);
die("sent: Unable to allocate data section for XImage");
if (!XInitImage(img->ximg)) if (!XInitImage(img->ximg))
die("sent: Unable to initiate XImage"); die("sent: Unable to initiate XImage");
@ -583,8 +578,7 @@ xloadfonts()
char *fstrs[LEN(fontfallbacks)]; char *fstrs[LEN(fontfallbacks)];
for (j = 0; j < LEN(fontfallbacks); j++) { for (j = 0; j < LEN(fontfallbacks); j++) {
if (!(fstrs[j] = malloc(MAXFONTSTRLEN))) fstrs[j] = ecalloc(1, MAXFONTSTRLEN);
die("sent: Unable to allocate fontstring:");
} }
for (i = 0; i < NUMFONTSCALES; i++) { for (i = 0; i < NUMFONTSCALES; i++) {