From: Takashi Iwai Subject: Re: [PATCH] alsa-lib: minor malloc changes Date: Fri, 13 Dec 2013 09:52:51 +0100 Message-ID: References: <1386910040-14324-1-git-send-email-olivier@trillion01.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id BB18F2615DC for ; Fri, 13 Dec 2013 09:52:51 +0100 (CET) In-Reply-To: <1386910040-14324-1-git-send-email-olivier@trillion01.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Olivier Langlois Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Thu, 12 Dec 2013 23:47:20 -0500, Olivier Langlois wrote: > > replace malloc + memset with calloc since calloc may skip the memset if > returned memory comes directly from sbrk() > > use malloc instead of malloc if first thing done with allocated memory is > to flip all bits to 1. > > Signed-off-by: Olivier Langlois Thanks, applied. Takashi > --- > src/alisp/alisp.c | 3 +-- > src/pcm/pcm_ladspa.c | 2 +- > 2 files changed, 2 insertions(+), 3 deletions(-) > > diff --git a/src/alisp/alisp.c b/src/alisp/alisp.c > index 1796c33..3c61bb1 100644 > --- a/src/alisp/alisp.c > +++ b/src/alisp/alisp.c > @@ -3202,12 +3202,11 @@ int alsa_lisp(struct alisp_cfg *cfg, struct alisp_instance **_instance) > struct alisp_object *p, *p1; > int i, j, retval = 0; > > - instance = (struct alisp_instance *)malloc(sizeof(struct alisp_instance)); > + instance = (struct alisp_instance *)calloc(1, sizeof(struct alisp_instance)); > if (instance == NULL) { > nomem(); > return -ENOMEM; > } > - memset(instance, 0, sizeof(struct alisp_instance)); > instance->verbose = cfg->verbose && cfg->vout; > instance->warning = cfg->warning && cfg->wout; > instance->debug = cfg->debug && cfg->dout; > diff --git a/src/pcm/pcm_ladspa.c b/src/pcm/pcm_ladspa.c > index 0a9c52e..9ce5242 100644 > --- a/src/pcm/pcm_ladspa.c > +++ b/src/pcm/pcm_ladspa.c > @@ -1326,7 +1326,7 @@ static int snd_pcm_ladspa_parse_bindings(snd_pcm_ladspa_plugin_t *lplug, > count = (unsigned int)(channel + 1); > } > if (count > 0) { > - array = (unsigned int *)calloc(count, sizeof(unsigned int)); > + array = (unsigned int *)malloc(count * sizeof(unsigned int)); > if (! array) > return -ENOMEM; > memset(array, 0xff, count * sizeof(unsigned int)); > -- > 1.8.5.1 > > _______________________________________________ > Alsa-devel mailing list > Alsa-devel@alsa-project.org > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel >