[go: nahoru, domu]

Skip to content

Commit

Permalink
Merge branch 'stbds-arraddn' of https://github.com/HeroicKatora/stb i…
Browse files Browse the repository at this point in the history
…nto working
  • Loading branch information
Sean Barrett committed Jul 13, 2020
2 parents 1c81674 + b67dabe commit 67881b6
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions stb_ds.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,16 @@ DOCUMENTATION
Inserts n uninitialized items into array a starting at a[p],
moving the rest of the array over.
arraddn:
T* arraddn(T* a, int n)
arraddnptr:
T* arraddnptr(T* a, int n)
Appends n uninitialized items onto array at the end.
Returns a pointer to the first uninitialized item added.
arraddnoff:
size_t arraddnoff(T* a, int n)
Appends n uninitialized items onto array at the end.
Returns the index of the first uninitialized item added.
arrdel:
void arrdel(T* a, int p);
Deletes the element at a[p], moving the rest of the array over.
Expand Down Expand Up @@ -370,6 +375,7 @@ CREDITS
Andy Durdin
Shane Liesegang
Vinh Truong
Andreas Molzer
*/

#ifdef STBDS_UNIT_TESTS
Expand All @@ -389,6 +395,9 @@ CREDITS
#define arrpush stbds_arrput
#define arrpop stbds_arrpop
#define arrfree stbds_arrfree
#define arraddnptr stbds_arraddnptr
#define arraddnoff stbds_arraddnoff
// deprecated
#define arraddn stbds_arraddn
#define arrsetlen stbds_arrsetlen
#define arrlast stbds_arrlast
Expand Down Expand Up @@ -527,7 +536,10 @@ 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))
// deprecated
#define stbds_arraddn(a,n) ((void)(stbds_arraddnoff(a, n)))
#define stbds_arraddnptr(a,n) (stbds_arrmaybegrow(a,n), stbds_header(a)->length += (n), &(a)[stbds_header(a)->length-(n)])
#define stbds_arraddnoff(a,n) (stbds_arrmaybegrow(a,n), stbds_header(a)->length += (n), 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)
Expand Down

0 comments on commit 67881b6

Please sign in to comment.