From aacc7445a9629968ac33c8afd3875d5d91c60a12 Mon Sep 17 00:00:00 2001 From: Martin Nilsson <mani@lysator.liu.se> Date: Fri, 1 Oct 2010 16:12:10 +0200 Subject: [PATCH] xcalloc gixes pre-zeroed memory. Rev: src/modules/Image/encodings/psd.c:1.48 Rev: src/modules/Image/encodings/tga.c:1.43 --- src/modules/Image/encodings/psd.c | 7 +++---- src/modules/Image/encodings/tga.c | 7 ++----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/modules/Image/encodings/psd.c b/src/modules/Image/encodings/psd.c index fc3db9f628..731bb2549c 100644 --- a/src/modules/Image/encodings/psd.c +++ b/src/modules/Image/encodings/psd.c @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: psd.c,v 1.47 2008/01/19 15:28:27 grubba Exp $ +|| $Id: psd.c,v 1.48 2010/10/01 14:12:10 nilsson Exp $ */ #include "global.h" @@ -213,9 +213,8 @@ static void decode_layers_and_masks( struct psd_image *dst, while( count-- ) { unsigned int cnt; - struct layer *l= - layer = (struct layer *)xalloc( sizeof( struct layer )); - MEMSET(layer, 0, sizeof(struct layer)); + struct layer *l= + layer = (struct layer *)xcalloc( sizeof( struct layer ), 1); layer->next = dst->first_layer; if(dst->first_layer) dst->first_layer->prev = layer; dst->first_layer = layer; diff --git a/src/modules/Image/encodings/tga.c b/src/modules/Image/encodings/tga.c index e343c01dc6..ad76fc4847 100644 --- a/src/modules/Image/encodings/tga.c +++ b/src/modules/Image/encodings/tga.c @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: tga.c,v 1.42 2008/01/27 20:28:41 grubba Exp $ +|| $Id: tga.c,v 1.43 2010/10/01 14:12:10 nilsson Exp $ */ /* @@ -570,10 +570,7 @@ static struct image_alpha ReadImage(struct buffer *fp, struct tga_header *hdr) pelbytes = ROUNDUP_DIVIDE (hdr->colorMapSize, 8); colors = length + index; - cmap = malloc (colors * pelbytes); - - /* Zero the entries up to the beginning of the map. */ - MEMSET (cmap, 0, index * pelbytes); + cmap = xcalloc (colors * pelbytes, 1); /* Read in the rest of the colormap. */ if (std_fread (cmap + (index * pelbytes), pelbytes, length, fp) != length) -- GitLab