]> git.alsa-project.org Git - alsa-lib.git/commitdiff
minor malloc changes
authorOlivier Langlois <olivier@trillion01.com>
Fri, 13 Dec 2013 04:47:20 +0000 (23:47 -0500)
committerTakashi Iwai <tiwai@suse.de>
Fri, 13 Dec 2013 08:43:51 +0000 (09:43 +0100)
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 <olivier@trillion01.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
src/alisp/alisp.c
src/pcm/pcm_ladspa.c

index 1796c33c3faf51132a38b2d35b9ec3399313f0ef..3c61bb1754c345808bcdd0432b6f22adaa3a56dd 100644 (file)
@@ -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;
index 0a9c52e975e67876b4a0d45e5d5b267a1841e01d..9ce5242e235955c70593cc7baf870f63db39e7b2 100644 (file)
@@ -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));