Skip to content
Myr

Split arraddn into pointer and index return

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

authored by Andreas Molzer · committed by Andreas Molzer · parent e423b41 · Browse files · 1 file+11 added−4 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+11 added−4 removed

  • other:+11 added−4 removed

1 file+11 added−4 removed

modified:stb_ds.h+11 added-4 removed
106 unmodified lines
107 void arrins(T* a, int p, int n);108 Inserts n uninitialized items into array a starting at a[p],109 moving the rest of the array over.110111 arraddn:112 T* arraddn(T* a, int n)111 arraddnptr:112 T* arraddnptr(T* a, int n)113 Appends n uninitialized items onto array at the end.114 Returns a pointer to the first uninitialized item added.115116 arraddnoff:117 size_t arraddnoff(T* a, int n)118 Appends n uninitialized items onto array at the end.119 Returns the index of the first uninitialized item added.120121 arrdel:122 void arrdel(T* a, int p);123 Deletes the element at a[p], moving the rest of the array over.124
269 unmodified lines
394#define arrput stbds_arrput395#define arrpush stbds_arrput396#define arrpop stbds_arrpop397#define arrfree stbds_arrfree393#define arraddn stbds_arraddn398#define arraddnptr stbds_arraddnptr399#define arraddnoff stbds_arraddnoff400#define arrsetlen stbds_arrsetlen401#define arrlast stbds_arrlast402#define arrins stbds_arrins403#define arrinsn stbds_arrinsn
123 unmodified lines
527#define stbds_arrlenu(a) ((a) ? stbds_header(a)->length : 0)528#define stbds_arrput(a,v) (stbds_arrmaybegrow(a,1), (a)[stbds_header(a)->length++] = (v))529#define stbds_arrpush stbds_arrput // synonym530#define stbds_arrpop(a) (stbds_header(a)->length--, (a)[stbds_header(a)->length])525#define stbds_arraddn(a,n) (stbds_arrmaybegrow(a,n), stbds_header(a)->length += (n), &(a)[stbds_header(a)->length-(n)])531#define stbds_arraddnptr(a,n) (stbds_arrmaybegrow(a,n), stbds_header(a)->length += (n), &(a)[stbds_header(a)->length-(n)])532#define stbds_arraddnoff(a,n) (stbds_arrmaybegrow(a,n), stbds_header(a)->length += (n), stbds_header(a)->length-(n))533#define stbds_arrlast(a) ((a)[stbds_header(a)->length-1])534#define stbds_arrfree(a) ((void) ((a) ? STBDS_FREE(NULL,stbds_header(a)) : (void)0), (a)=NULL)535#define stbds_arrdel(a,i) stbds_arrdeln(a,i,1)536#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