Skip to content
Myr

Merge branch 'patch-1' of https://github.com/t-mw/stb into dev

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

authored by Sean Barrett · committed by Sean Barrett · parents 95372dc, 2d82cd1 · Browse files · 1 file+20 added−18 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+20 added−18 removed

  • other:+20 added−18 removed

1 file+20 added−18 removed

modified:stb_ds.h+20 added-18 removed
379 unmodified lines
380 github:hashitaku381 github:srdjanstipic382 Macoy Madson383 Andreas Vennstrom384 Tobias Mansfield-Williams385*/386387#ifdef STBDS_UNIT_TESTS388#define _CRT_SECURE_NO_WARNINGS
145 unmodified lines
534#define stbds_header(t) ((stbds_array_header *) (t) - 1)535#define stbds_temp(t) stbds_header(t)->temp536#define stbds_temp_key(t) (*(char **) stbds_header(t)->hash_table)537537#define stbds_arrsetcap(a,n) (stbds_arrgrow(a,0,n))538#define stbds_arrsetlen(a,n) ((stbds_arrcap(a) < (size_t) (n) ? stbds_arrsetcap((a),(size_t)(n)),0 : 0), (a) ? stbds_header(a)->length = (size_t) (n) : 0)539#define stbds_arrcap(a) ((a) ? stbds_header(a)->capacity : 0)540#define stbds_arrlen(a) ((a) ? (ptrdiff_t) stbds_header(a)->length : 0)541#define stbds_arrlenu(a) ((a) ? stbds_header(a)->length : 0)542#define stbds_arrput(a,v) (stbds_arrmaybegrow(a,1), (a)[stbds_header(a)->length++] = (v))543#define stbds_arrpush stbds_arrput // synonym544#define stbds_arrpop(a) (stbds_header(a)->length--, (a)[stbds_header(a)->length])545#define stbds_arraddn(a,n) ((void)(stbds_arraddnoff(a, n))) // deprecated, use one of the following instead:546#define stbds_arraddnptr(a,n) (stbds_arrmaybegrow(a,n), stbds_header(a)->length += (n), &(a)[stbds_header(a)->length-(n)])547#define stbds_arraddnoff(a,n) (stbds_arrmaybegrow(a,n), stbds_header(a)->length += (n), stbds_header(a)->length-(n))548#define stbds_arrlast(a) ((a)[stbds_header(a)->length-1])549#define stbds_arrfree(a) ((void) ((a) ? stbds_arrfreef(a) : (void)0), (a)=NULL)550#define stbds_arrdel(a,i) stbds_arrdeln(a,i,1)551#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))552#define stbds_arrdelswap(a,i) ((a)[i] = stbds_arrlast(a), stbds_header(a)->length -= 1)553#define stbds_arrinsn(a,i,n) ((a)?stbds_temp(a)=(i):0,stbds_arraddn((a),(n)), memmove(&(a)[stbds_temp(a)+(n)], &(a)[stbds_temp(a)], sizeof *(a) * (stbds_header(a)->length-(n)-stbds_temp(a))))554#define stbds_arrins(a,i,v) (stbds_arrinsn((a),(i),1), (a)[i]=(v))538#define stbds_arrsetcap(a,n) (stbds_arrgrow(a,0,n))539#define stbds_arrsetlen(a,n) ((stbds_arrcap(a) < (size_t) (n) ? stbds_arrsetcap((a),(size_t)(n)),0 : 0), (a) ? stbds_header(a)->length = (size_t) (n) : 0)540#define stbds_arrcap(a) ((a) ? stbds_header(a)->capacity : 0)541#define stbds_arrlen(a) ((a) ? (ptrdiff_t) stbds_header(a)->length : 0)542#define stbds_arrlenu(a) ((a) ? stbds_header(a)->length : 0)543#define stbds_arrput(a,v) (stbds_arrmaybegrow(a,1), (a)[stbds_header(a)->length++] = (v))544#define stbds_arrpush stbds_arrput // synonym545#define stbds_arrpop(a) (stbds_header(a)->length--, (a)[stbds_header(a)->length])546#define stbds_arraddn(a,n) ((void)(stbds_arraddnindex(a, n))) // deprecated, use one of the following instead:547#define stbds_arraddnptr(a,n) (stbds_arrmaybegrow(a,n), stbds_header(a)->length += (n), &(a)[stbds_header(a)->length-(n)])548#define stbds_arraddnindex(a,n)(stbds_arrmaybegrow(a,n), stbds_header(a)->length += (n), stbds_header(a)->length-(n))549#define stbds_arraddnoff stbds_arraddnindex550#define stbds_arrlast(a) ((a)[stbds_header(a)->length-1])551#define stbds_arrfree(a) ((void) ((a) ? STBDS_FREE(NULL,stbds_header(a)) : (void)0), (a)=NULL)552#define stbds_arrdel(a,i) stbds_arrdeln(a,i,1)553#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))554#define stbds_arrdelswap(a,i) ((a)[i] = stbds_arrlast(a), stbds_header(a)->length -= 1)555#define stbds_arrinsn(a,i,n) (stbds_arraddn((a),(n)), memmove(&(a)[(i)+(n)], &(a)[i], sizeof *(a) * (stbds_header(a)->length-(n)-(i))))556#define stbds_arrins(a,i,v) (stbds_arrinsn((a),(i),1), (a)[i]=(v))557558#define stbds_arrmaybegrow(a,n) ((!(a) || stbds_header(a)->length + (n) > stbds_header(a)->capacity) \559 ? (stbds_arrgrow(a,n,0),0) : 0)560
1335 unmodified lines