Skip to content

Commit

Permalink
pcm: route plugin: allocate temporary array on stack only one time
Browse files Browse the repository at this point in the history
Fixes: #363
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
  • Loading branch information
perexg committed Jan 24, 2024
1 parent 55a758a commit a69ac97
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/pcm/pcm_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,11 @@ static int _snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_ent
snd_config_iterator_t i, inext;
unsigned int k;
int err;

long *scha = alloca(tt_ssize * sizeof(long));
if (scha == NULL)
return -ENOMEM;

for (k = 0; k < tt_csize * tt_ssize; ++k)
ttable[k] = 0.0;
snd_config_for_each(i, inext, tt) {
Expand All @@ -1172,7 +1177,6 @@ static int _snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_ent
snd_config_t *jnode = snd_config_iterator_entry(j);
double value;
int ss;
long *scha = alloca(tt_ssize * sizeof(long));
const char *id;
if (snd_config_get_id(jnode, &id) < 0)
continue;
Expand Down

0 comments on commit a69ac97

Please sign in to comment.