Skip to content

Commit

Permalink
ALSA: pcm: Use krealloc() for resizing the rules array
Browse files Browse the repository at this point in the history
Just a minor simplification.  Change from kcalloc() shouldn't matter
as each array element is fully initialized.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Takashi Iwai committed Mar 13, 2018
1 parent 5730f9f commit 09b9ddf
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions sound/core/pcm_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1129,16 +1129,12 @@ int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsigned int cond,
if (constrs->rules_num >= constrs->rules_all) {
struct snd_pcm_hw_rule *new;
unsigned int new_rules = constrs->rules_all + 16;
new = kcalloc(new_rules, sizeof(*c), GFP_KERNEL);
new = krealloc(constrs->rules, new_rules * sizeof(*c),
GFP_KERNEL);
if (!new) {
va_end(args);
return -ENOMEM;
}
if (constrs->rules) {
memcpy(new, constrs->rules,
constrs->rules_num * sizeof(*c));
kfree(constrs->rules);
}
constrs->rules = new;
constrs->rules_all = new_rules;
}
Expand Down

0 comments on commit 09b9ddf

Please sign in to comment.