Permalink
Browse files

fix stb_sdict_for()

  • Loading branch information...
Sean Barrett
Sean Barrett committed Jan 29, 2018
1 parent 3025377 commit db4d92891c78cdf32753b022b7081dd9a32d8aa6
Showing with 24 additions and 1 deletion.
  1. +24 −1 stb.h
25 stb.h
@@ -4246,12 +4246,22 @@ STB_EXTERN void stb_sdict_delete(stb_sdict *);
STB_EXTERN void * stb_sdict_change(stb_sdict *, char *str, void *p);
STB_EXTERN int stb_sdict_count(stb_sdict *d);
STB_EXTERN int stb_sdict_internal_limit(stb_sdict *d);
STB_EXTERN char * stb_sdict_internal_key(stb_sdict *d, int n);
STB_EXTERN void * stb_sdict_internal_value(stb_sdict *d, int n);
#define stb_sdict_for(d,i,q,z) \
for(i=0; i < (d)->limit ? q=(d)->table[i].k,z=(d)->table[i].v,1 : 0; ++i) \
for(i=0; i < stb_sdict_internal_limit(d) ? (q=stb_sdict_internal_key(d,i),z=stb_sdict_internal_value(d,i),1) : 0; ++i) \
if (q==NULL||q==(void *) 1);else // reversed makes macro friendly
#ifdef STB_DEFINE
// if in same translation unit, for speed, don't call accessors
#undef stb_sdict_for
#define stb_sdict_for(d,i,q,z) \
for(i=0; i < (d)->limit ? (q=(d)->table[i].k,z=(d)->table[i].v,1) : 0; ++i) \
if (q==NULL||q==(void *) 1);else // reversed makes macro friendly
#define STB_DEL ((void *) 1)
#define STB_SDEL ((char *) 1)
@@ -4271,6 +4281,19 @@ int stb_sdict_count(stb_sdict *a)
return a->count;
}
int stb_sdict_internal_limit(stb_sdict *a)
{
return a->limit;
}
char* stb_sdict_internal_key(stb_sdict *a, int n)
{
return a->table[n].k;
}
void* stb_sdict_internal_value(stb_sdict *a, int n)
{
return a->table[n].v;
}
stb_sdict * stb_sdict_new(int use_arena)
{
stb_sdict *d = stb_sdict_create();

0 comments on commit db4d928

Please sign in to comment.