diff options
author | Chris Robinson <[email protected]> | 2014-03-21 00:54:37 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-03-21 01:23:01 -0700 |
commit | ff63188cc2eb307eb874350e5281733d9c50f258 (patch) | |
tree | c422ded3a9125811f5658fb279aef96245c78268 /Alc/helpers.c | |
parent | e6e3937fa9d1d192bc26b900438b45c0e6eb5be2 (diff) |
Add a generic vector interface and use it for the active effect slots
Diffstat (limited to 'Alc/helpers.c')
-rw-r--r-- | Alc/helpers.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Alc/helpers.c b/Alc/helpers.c index 66ca58a9..80aab889 100644 --- a/Alc/helpers.c +++ b/Alc/helpers.c @@ -86,6 +86,7 @@ DEFINE_DEVPROPKEY(DEVPKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, #include "alMain.h" #include "atomic.h" #include "uintmap.h" +#include "vector.h" #include "compat.h" @@ -700,6 +701,26 @@ void WriteUnlock(RWLock *lock) } +ALboolean vector_reserve(void *ptr, size_t orig_count, size_t base_size, size_t obj_count, size_t obj_size) +{ + if(orig_count < obj_count) + { + vector_ *vecptr = ptr; + void *temp; + + /* Need to be explicit with the caller type's base size, because it + * could have extra padding between the count and array start (that is, + * sizeof(*vector_) may not equal base_size). */ + temp = realloc(*vecptr, base_size + obj_size*obj_count); + if(temp == NULL) return AL_FALSE; + + *vecptr = temp; + (*vecptr)->Max = obj_count; + } + return AL_TRUE; +} + + void InitUIntMap(UIntMap *map, ALsizei limit) { map->array = NULL; |