From 936a79da7dccfe819b616c044c9d4930ef331d9e Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 10 Aug 2014 09:12:08 -0700 Subject: Give NULL for null-vector iterators --- Alc/helpers.c | 4 +++- Alc/vector.h | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'Alc') diff --git a/Alc/helpers.c b/Alc/helpers.c index 39a704fb..52fdf20a 100644 --- a/Alc/helpers.c +++ b/Alc/helpers.c @@ -644,7 +644,9 @@ ALboolean vector_insert(char *ptr, size_t base_size, size_t obj_size, void *ins_ vector_ *vecptr = (vector_*)ptr; if(datstart != datend) { - ptrdiff_t ins_elem = ((char*)ins_pos - ((char*)(*vecptr) + base_size)) / obj_size; + ptrdiff_t ins_elem = (*vecptr ? ((char*)ins_pos - ((char*)(*vecptr) + base_size)) : + ((char*)ins_pos - (char*)NULL)) / + obj_size; ptrdiff_t numins = ((const char*)datend - (const char*)datstart) / obj_size; assert(numins > 0); diff --git a/Alc/vector.h b/Alc/vector.h index b04b65eb..9cac216e 100644 --- a/Alc/vector.h +++ b/Alc/vector.h @@ -39,8 +39,8 @@ ALboolean vector_resize(char *ptr, size_t base_size, size_t obj_count, size_t ob #define VECTOR_CAPACITY(_x) ((_x) ? (_x)->Capacity : 0) #define VECTOR_SIZE(_x) ((_x) ? (_x)->Size : 0) -#define VECTOR_ITER_BEGIN(_x) ((_x)->Data + 0) -#define VECTOR_ITER_END(_x) ((_x)->Data + VECTOR_SIZE(_x)) +#define VECTOR_ITER_BEGIN(_x) ((_x) ? (_x)->Data + 0 : NULL) +#define VECTOR_ITER_END(_x) ((_x) ? (_x)->Data + (_x)->Size : NULL) ALboolean vector_insert(char *ptr, size_t base_size, size_t obj_size, void *ins_pos, const void *datstart, const void *datend); #ifdef __GNUC__ -- cgit v1.2.3