summaryrefslogtreecommitdiffstats
path: root/Alc/ALc.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-01-23 23:16:55 -0800
committerChris Robinson <[email protected]>2011-01-23 23:16:55 -0800
commit6c4add67e182f40dcd856216c48079c4fb04455d (patch)
treef1087b6946e6846fa58c6890afc0d45258597bec /Alc/ALc.c
parent2b7324c06ee9bb2d555a26e5f4b4395f0d044ef3 (diff)
Don't duplicate the device list append function
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r--Alc/ALc.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index a2b74644..98637c17 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -585,31 +585,37 @@ static void ProbeCaptureDeviceList()
}
+static void AppendList(const ALCchar *name, ALCchar **List, size_t *ListSize)
+{
+ size_t len = strlen(name);
+ void *temp;
+
+ if(len == 0)
+ return;
+
+ temp = realloc(*List, (*ListSize) + len + 2);
+ if(!temp)
+ {
+ AL_PRINT("Realloc failed to add %s!\n", name);
+ return;
+ }
+ *List = temp;
+
+ memcpy((*List)+(*ListSize), name, len+1);
+ *ListSize += len+1;
+ (*List)[*ListSize] = 0;
+}
+
#define DECL_APPEND_LIST_FUNC(type) \
void Append##type##List(const ALCchar *name) \
-{ \
- size_t len = strlen(name); \
- void *temp; \
- \
- if(len == 0) \
- return; \
- \
- temp = realloc(alc##type##List, alc##type##ListSize + len + 2); \
- if(!temp) \
- { \
- AL_PRINT("Realloc failed to add %s!\n", name); \
- return; \
- } \
- alc##type##List = temp; \
- memcpy(alc##type##List+alc##type##ListSize, name, len+1); \
- alc##type##ListSize += len+1; \
- alc##type##List[alc##type##ListSize] = 0; \
-}
+{ AppendList(name, &alc##type##List, &alc##type##ListSize); }
DECL_APPEND_LIST_FUNC(Device)
DECL_APPEND_LIST_FUNC(AllDevice)
DECL_APPEND_LIST_FUNC(CaptureDevice)
+#undef DECL_APPEND_LIST_FUNC
+
void al_print(const char *fname, unsigned int line, const char *fmt, ...)
{