Fix arraddn returning index instead of pointer

The documentation of that operation already said:
> Returns a pointer to the first uninitialized item added.

This also makes a lot of sense, allowing easy initialization. But the
implementation returned the index of the first uninitialized element
instead.
This commit is contained in:
Andreas Molzer 2020-03-24 15:30:20 +01:00
parent f54acd4e13
commit e423b41e74
No known key found for this signature in database
GPG Key ID: 8BFB6B35887B56B8
1 changed files with 2 additions and 1 deletions

View File

@ -370,6 +370,7 @@ CREDITS
Andy Durdin
Shane Liesegang
Vinh Truong
Andreas Molzer
*/
#ifdef STBDS_UNIT_TESTS
@ -521,7 +522,7 @@ extern void * stbds_shmode_func(size_t elemsize, int mode);
#define stbds_arrput(a,v) (stbds_arrmaybegrow(a,1), (a)[stbds_header(a)->length++] = (v))
#define stbds_arrpush stbds_arrput // synonym
#define stbds_arrpop(a) (stbds_header(a)->length--, (a)[stbds_header(a)->length])
#define stbds_arraddn(a,n) (stbds_arrmaybegrow(a,n), stbds_header(a)->length += (n), stbds_header(a)->length-(n))
#define stbds_arraddn(a,n) (stbds_arrmaybegrow(a,n), stbds_header(a)->length += (n), &(a)[stbds_header(a)->length-(n)])
#define stbds_arrlast(a) ((a)[stbds_header(a)->length-1])
#define stbds_arrfree(a) ((void) ((a) ? STBDS_FREE(NULL,stbds_header(a)) : (void)0), (a)=NULL)
#define stbds_arrdel(a,i) stbds_arrdeln(a,i,1)