diff options
author | Chris Robinson <[email protected]> | 2014-04-13 17:06:18 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-04-13 17:06:18 -0700 |
commit | cce9609b9ec69f8d139cee139d79ec01c9e2b533 (patch) | |
tree | 52fa5379fa412ad7c567c440cd492c3a773069b9 /Alc/helpers.c | |
parent | e76bc53d3724463f5375d303e13f385875f596e6 (diff) |
Avoid referencing the start iterator twice for vector insertion
Diffstat (limited to 'Alc/helpers.c')
-rw-r--r-- | Alc/helpers.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Alc/helpers.c b/Alc/helpers.c index 7607493e..2fbb588b 100644 --- a/Alc/helpers.c +++ b/Alc/helpers.c @@ -796,11 +796,12 @@ 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, ptrdiff_t numins) +ALboolean vector_insert(void *ptr, size_t base_size, size_t obj_size, ptrdiff_t ins_elem, const void *datstart, const void *datend) { vector_ *vecptr = ptr; - if(*vecptr || numins > 0) + if(datstart != datend) { + 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; if(ins_elem < (*vecptr)->Size) |