diff options
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/alstring.h | 15 | ||||
-rw-r--r-- | Alc/backends/alsa.c | 2 | ||||
-rw-r--r-- | Alc/backends/dsound.c | 6 | ||||
-rw-r--r-- | Alc/backends/mmdevapi.c | 2 | ||||
-rw-r--r-- | Alc/backends/pulseaudio.c | 2 | ||||
-rw-r--r-- | Alc/backends/winmm.c | 8 | ||||
-rw-r--r-- | Alc/helpers.c | 1 | ||||
-rw-r--r-- | Alc/midi/sf2load.c | 7 | ||||
-rw-r--r-- | Alc/vector.h | 20 |
9 files changed, 31 insertions, 32 deletions
diff --git a/Alc/alstring.h b/Alc/alstring.h index 5b37a483..d5f64418 100644 --- a/Alc/alstring.h +++ b/Alc/alstring.h @@ -7,13 +7,13 @@ typedef char al_string_char_type; -DECL_VECTOR(al_string_char_type) +TYPEDEF_VECTOR(al_string_char_type, al_string) -typedef vector_al_string_char_type al_string; -typedef const_vector_al_string_char_type const_al_string; - -#define AL_STRING_INIT(_x) VECTOR_INIT(_x) -#define AL_STRING_DEINIT(_x) VECTOR_DEINIT(_x) +inline void al_string_deinit(al_string *str) +{ VECTOR_DEINIT(*str); } +#define AL_STRING_INIT(_x) do { (_x) = (al_string)NULL; } while(0) +#define AL_STRING_INIT_STATIC() ((al_string)NULL) +#define AL_STRING_DEINIT(_x) al_string_deinit(&(_x)); inline ALsizei al_string_length(const_al_string str) { return VECTOR_SIZE(str); } @@ -42,7 +42,4 @@ void al_string_append_range(al_string *str, const al_string_char_type *from, con void al_string_copy_wcstr(al_string *str, const wchar_t *from); #endif - -DECL_VECTOR(al_string) - #endif /* ALSTRING_H */ diff --git a/Alc/backends/alsa.c b/Alc/backends/alsa.c index 0712a412..2d3a8425 100644 --- a/Alc/backends/alsa.c +++ b/Alc/backends/alsa.c @@ -230,7 +230,7 @@ typedef struct { al_string name; al_string device_name; } DevMap; -DECL_VECTOR(DevMap) +TYPEDEF_VECTOR(DevMap, vector_DevMap) static vector_DevMap PlaybackDevices; static vector_DevMap CaptureDevices; diff --git a/Alc/backends/dsound.c b/Alc/backends/dsound.c index 3ca398ed..f5dcfe59 100644 --- a/Alc/backends/dsound.c +++ b/Alc/backends/dsound.c @@ -109,10 +109,10 @@ typedef struct { al_string name; GUID guid; } DevMap; -DECL_VECTOR(DevMap) +TYPEDEF_VECTOR(DevMap, vector_DevMap) -vector_DevMap PlaybackDevices; -vector_DevMap CaptureDevices; +static vector_DevMap PlaybackDevices; +static vector_DevMap CaptureDevices; static void clear_devlist(vector_DevMap *list) { diff --git a/Alc/backends/mmdevapi.c b/Alc/backends/mmdevapi.c index d732c3e1..430e1cb8 100644 --- a/Alc/backends/mmdevapi.c +++ b/Alc/backends/mmdevapi.c @@ -65,7 +65,7 @@ typedef struct { al_string name; WCHAR *devid; } DevMap; -DECL_VECTOR(DevMap) +TYPEDEF_VECTOR(DevMap, vector_DevMap) static void clear_devlist(vector_DevMap *list) { diff --git a/Alc/backends/pulseaudio.c b/Alc/backends/pulseaudio.c index 58252240..b392f18e 100644 --- a/Alc/backends/pulseaudio.c +++ b/Alc/backends/pulseaudio.c @@ -458,7 +458,7 @@ typedef struct { al_string name; al_string device_name; } DevMap; -DECL_VECTOR(DevMap) +TYPEDEF_VECTOR(DevMap, vector_DevMap) static vector_DevMap PlaybackDevices; static vector_DevMap CaptureDevices; diff --git a/Alc/backends/winmm.c b/Alc/backends/winmm.c index 624af37a..cad66470 100644 --- a/Alc/backends/winmm.c +++ b/Alc/backends/winmm.c @@ -55,17 +55,13 @@ typedef struct { } WinMMData; +TYPEDEF_VECTOR(al_string, vector_al_string) static vector_al_string PlaybackDevices; static vector_al_string CaptureDevices; static void clear_devlist(vector_al_string *list) { - al_string *iter, *end; - - iter = VECTOR_ITER_BEGIN(*list); - end = VECTOR_ITER_END(*list); - for(;iter != end;iter++) - AL_STRING_DEINIT(*iter); + VECTOR_FOR_EACH(al_string, *list, al_string_deinit); VECTOR_RESIZE(*list, 0); } diff --git a/Alc/helpers.c b/Alc/helpers.c index df370206..f87b935c 100644 --- a/Alc/helpers.c +++ b/Alc/helpers.c @@ -653,6 +653,7 @@ ALboolean vector_insert(void *ptr, size_t base_size, size_t obj_size, void *ins_ } +extern inline void al_string_deinit(al_string *str); extern inline ALsizei al_string_length(const_al_string str); extern inline ALboolean al_string_empty(const_al_string str); extern inline const al_string_char_type *al_string_get_cstr(const_al_string str); diff --git a/Alc/midi/sf2load.c b/Alc/midi/sf2load.c index 933166ad..4ee691ba 100644 --- a/Alc/midi/sf2load.c +++ b/Alc/midi/sf2load.c @@ -307,12 +307,9 @@ static void RiffHdr_read(RiffHdr *self, Reader *stream) } -DECL_VECTOR(Generator) -DECL_VECTOR(Modulator) - typedef struct GenModList { - vector_Generator gens; - vector_Modulator mods; + VECTOR(Generator) gens; + VECTOR(Modulator) mods; } GenModList; static void GenModList_Construct(GenModList *self) diff --git a/Alc/vector.h b/Alc/vector.h index 5e169f24..944cccc2 100644 --- a/Alc/vector.h +++ b/Alc/vector.h @@ -11,15 +11,23 @@ typedef struct vector__s { ALsizei Size; } *vector_; -#define DECL_VECTOR(T) typedef struct vector_##T##_s { \ +#define TYPEDEF_VECTOR(T, N) typedef struct { \ ALsizei Capacity; \ ALsizei Size; \ T Data[]; \ -} *vector_##T; \ -typedef const struct vector_##T##_s *const_vector_##T; +} _##N; \ +typedef _##N* N; \ +typedef const _##N* const_##N; -#define VECTOR_INIT(_x) do { (_x) = NULL; } while(0) -#define VECTOR_DEINIT(_x) do { free((_x)); (_x) = NULL; } while(0) +#define VECTOR(T) struct { \ + ALsizei Capacity; \ + ALsizei Size; \ + T Data[]; \ +}* + +#define VECTOR_INIT(_x) do { (_x) = NULL; } while(0) +#define VECTOR_INIT_STATIC() NULL +#define VECTOR_DEINIT(_x) do { free((_x)); (_x) = NULL; } while(0) /* Helper to increase a vector's reserve. Do not call directly. */ ALboolean vector_reserve(void *ptr, size_t base_size, size_t obj_count, size_t obj_size, ALboolean exact); @@ -63,7 +71,7 @@ ALboolean vector_insert(void *ptr, size_t base_size, size_t obj_size, void *ins_ _t *_iter = VECTOR_ITER_BEGIN((_x)); \ _t *_end = VECTOR_ITER_END((_x)); \ for(;_iter != _end;++_iter) \ - (_f)(_iter); \ + _f(_iter); \ } while(0) #endif /* AL_VECTOR_H */ |