ASoC: dapm: Avoid duplicating immutable strings
authorLars-Peter Clausen <lars@metafoo.de>
Tue, 21 Jul 2015 16:11:08 +0000 (18:11 +0200)
committerMark Brown <broonie@kernel.org>
Tue, 21 Jul 2015 17:08:53 +0000 (18:08 +0100)
commit480689617510381391b3d906549477b948d9c4bc
tree75a0cf1d9e9e84d91b57e462a1939d7c4a493df3
parentb97e26980f6c13afad4c249b60a8dca7f5f86116
ASoC: dapm: Avoid duplicating immutable strings

When creating a new widget from a template the name string of the template
is duplicated for the newly created widget. This is necessary because in
some cases the string might be stored on the stack or other volatile
memory locations.

But most of the time the string is static const data, which means it is
possible to use it directly without having to worry that it might get freed
or changed.

Use kstrdup_const() to handle duplicating the string. This function is
capable of detecting whether a string is immutable and if it is returns the
input without duplicating it. This will slightly reduce the runtime memory
footprint of DAPM and also speed up initialization.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-dapm.c
This page took 0.024676 seconds and 5 git commands to generate.