summaryrefslogtreecommitdiffstats
path: root/Alc/helpers.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-04-13 18:42:41 -0700
committerChris Robinson <[email protected]>2014-04-13 18:42:41 -0700
commit0ef87227c19f71c063d9d78871663f20402b5924 (patch)
tree2c6cb9825bd4b5bd66d75e750a9521f5ed4979ac /Alc/helpers.c
parentcce9609b9ec69f8d139cee139d79ec01c9e2b533 (diff)
Pass in the vector insertion point as a pointer
Diffstat (limited to 'Alc/helpers.c')
-rw-r--r--Alc/helpers.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Alc/helpers.c b/Alc/helpers.c
index 2fbb588b..97f7988e 100644
--- a/Alc/helpers.c
+++ b/Alc/helpers.c
@@ -796,14 +796,16 @@ ALboolean vector_resize(void *ptr, size_t base_size, size_t obj_count, size_t ob
return AL_TRUE;
}
-ALboolean vector_insert(void *ptr, size_t base_size, size_t obj_size, ptrdiff_t ins_elem, const void *datstart, const void *datend)
+ALboolean vector_insert(void *ptr, size_t base_size, size_t obj_size, void *ins_pos, const void *datstart, const void *datend)
{
vector_ *vecptr = ptr;
if(datstart != datend)
{
+ ptrdiff_t ins_elem = ((char*)ins_pos - ((char*)(*vecptr) + base_size)) / obj_size;
ptrdiff_t numins = ((const char*)datend - (const char*)datstart) / obj_size;
if(!vector_reserve(vecptr, base_size, VECTOR_SIZE(*vecptr)+numins, obj_size, AL_TRUE))
return AL_FALSE;
+ /* NOTE: ins_pos may have been invalidated if *vecptr moved. Use ins_elem instead. */
if(ins_elem < (*vecptr)->Size)
{
memmove((char*)(*vecptr) + base_size + ((ins_elem+numins)*obj_size),