Skip to content
Myr

Fix arraddn returning index instead of pointer

Before adoption: this commit came in with the history the project adopted, so no landing records it.

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.

authored by Andreas Molzer · committed by Andreas Molzer · parent f54acd4 · Browse files · 1 file+2 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+2 added−1 removed

  • other:+2 added−1 removed

1 file+2 added−1 removed

modified:stb_ds.h+2 added-1 removed
368 unmodified lines
369 Bugfixes:370 Andy Durdin371 Shane Liesegang372 Vinh Truong373 Andreas Molzer374*/375376#ifdef STBDS_UNIT_TESTS377#define _CRT_SECURE_NO_WARNINGS
143 unmodified lines
521#define stbds_arrlenu(a) ((a) ? stbds_header(a)->length : 0)522#define stbds_arrput(a,v) (stbds_arrmaybegrow(a,1), (a)[stbds_header(a)->length++] = (v))523#define stbds_arrpush stbds_arrput // synonym524#define stbds_arrpop(a) (stbds_header(a)->length--, (a)[stbds_header(a)->length])524#define stbds_arraddn(a,n) (stbds_arrmaybegrow(a,n), stbds_header(a)->length += (n), stbds_header(a)->length-(n))525#define stbds_arraddn(a,n) (stbds_arrmaybegrow(a,n), stbds_header(a)->length += (n), &(a)[stbds_header(a)->length-(n)])526#define stbds_arrlast(a) ((a)[stbds_header(a)->length-1])527#define stbds_arrfree(a) ((void) ((a) ? STBDS_FREE(NULL,stbds_header(a)) : (void)0), (a)=NULL)528#define stbds_arrdel(a,i) stbds_arrdeln(a,i,1)529#define stbds_arrdeln(a,i,n) (memmove(&(a)[i], &(a)[(i)+(n)], sizeof *(a) * (stbds_header(a)->length-(n)-(i))), stbds_header(a)->length -= (n))
1300 unmodified lines