aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-03-25 18:16:03 -0700
committerChris Robinson <[email protected]>2014-03-25 18:16:03 -0700
commit045959e9c00979128679ca77b10b929182fe3397 (patch)
treecba018b5a2aecfae723e372694a0281fdf936614 /OpenAL32
parent03fd2b826658bae6bd975957c4af26ae42481756 (diff)
Use C99 VLA instead of alloca when available
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alMain.h6
-rw-r--r--OpenAL32/sample_cvt.c12
2 files changed, 10 insertions, 8 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 04514b5e..3d1f062a 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -314,6 +314,12 @@ typedef ptrdiff_t ALsizeiptrEXT;
#define FORCE_ALIGN
#endif
+#ifdef HAVE_C99_VLA
+#define DECL_VLA(T, _name, _size) T _name[(_size)]
+#else
+#define DECL_VLA(T, _name, _size) T *_name = alloca((_size) * sizeof(T))
+#endif
+
#ifndef PATH_MAX
#ifdef MAX_PATH
#define PATH_MAX MAX_PATH
diff --git a/OpenAL32/sample_cvt.c b/OpenAL32/sample_cvt.c
index a4c59d9d..903ec8ca 100644
--- a/OpenAL32/sample_cvt.c
+++ b/OpenAL32/sample_cvt.c
@@ -917,10 +917,9 @@ static void Convert_##T##_ALima4(T *dst, const ALima4 *src, ALuint numchans, \
ALuint len, ALuint align) \
{ \
ALsizei byte_align = ((align-1)/2 + 4) * numchans; \
+ DECL_VLA(ALshort, tmp, align*numchans); \
ALuint i, j, k; \
- ALshort *tmp; \
\
- tmp = alloca(align*numchans*sizeof(*tmp)); \
for(i = 0;i < len;i += align) \
{ \
DecodeIMA4Block(tmp, src, numchans, align); \
@@ -968,10 +967,9 @@ static void Convert_ALima4_##T(ALima4 *dst, const T *src, ALuint numchans, \
ALint sample[MAX_INPUT_CHANNELS] = {0,0,0,0,0,0,0,0}; \
ALint index[MAX_INPUT_CHANNELS] = {0,0,0,0,0,0,0,0}; \
ALsizei byte_align = ((align-1)/2 + 4) * numchans; \
+ DECL_VLA(ALshort, tmp, align*numchans); \
ALuint i, j, k; \
- ALshort *tmp; \
\
- tmp = alloca(align*numchans*sizeof(*tmp)); \
for(i = 0;i < len;i += align) \
{ \
for(j = 0;j < align;j++) \
@@ -1020,10 +1018,9 @@ static void Convert_##T##_ALmsadpcm(T *dst, const ALmsadpcm *src, \
ALuint align) \
{ \
ALsizei byte_align = ((align-2)/2 + 7) * numchans; \
+ DECL_VLA(ALshort, tmp, align*numchans); \
ALuint i, j, k; \
- ALshort *tmp; \
\
- tmp = alloca(align*numchans*sizeof(*tmp)); \
for(i = 0;i < len;i += align) \
{ \
DecodeMSADPCMBlock(tmp, src, numchans, align); \
@@ -1071,10 +1068,9 @@ static void Convert_ALmsadpcm_##T(ALmsadpcm *dst, const T *src, \
{ \
ALint sample[MAX_INPUT_CHANNELS] = {0,0,0,0,0,0,0,0}; \
ALsizei byte_align = ((align-2)/2 + 7) * numchans; \
+ DECL_VLA(ALshort, tmp, align*numchans); \
ALuint i, j, k; \
- ALshort *tmp; \
\
- tmp = alloca(align*numchans*sizeof(*tmp)); \
for(i = 0;i < len;i += align) \
{ \
for(j = 0;j < align;j++) \