[PATCH 04/34] pcm: remove alloca() from snd_pcm_get_params

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.

This commit obsolete usages of alloca() with automatic variables.

Signed-off-by: Takashi Sakamoto <o-takashi@xxxxxxxxxxxxx>
---
 src/pcm/pcm.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c
index 23655e6..f832399 100644
--- a/src/pcm/pcm.c
+++ b/src/pcm/pcm.c
@@ -8476,17 +8476,16 @@ int snd_pcm_get_params(snd_pcm_t *pcm,
                        snd_pcm_uframes_t *buffer_size,
                        snd_pcm_uframes_t *period_size)
 {
-	snd_pcm_hw_params_t *hw;
+	snd_pcm_hw_params_t params = {0};
 	int err;
 
 	assert(pcm);
-	snd_pcm_hw_params_alloca(&hw);
-	err = snd_pcm_hw_params_current(pcm, hw);
+	err = snd_pcm_hw_params_current(pcm, &params);
 	if (err < 0)
 	        return err;
-	err = INTERNAL(snd_pcm_hw_params_get_buffer_size)(hw, buffer_size);
+	err = INTERNAL(snd_pcm_hw_params_get_buffer_size)(&params, buffer_size);
 	if (err < 0)
 		return err;
-	return INTERNAL(snd_pcm_hw_params_get_period_size)(hw, period_size,
+	return INTERNAL(snd_pcm_hw_params_get_period_size)(&params, period_size,
 							   NULL);
 }
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux