stb_ds: use keyoffset in key comparison

This commit is contained in:
Sean Barrett 2020-07-13 02:42:37 -07:00
parent 523a14f3e1
commit dfdb7d9c14

View File

@ -1167,9 +1167,9 @@ size_t stbds_hash_bytes(void *p, size_t len, size_t seed)
static int stbds_is_key_equal(void *a, size_t elemsize, void *key, size_t keysize, size_t keyoffset, int mode, size_t i) static int stbds_is_key_equal(void *a, size_t elemsize, void *key, size_t keysize, size_t keyoffset, int mode, size_t i)
{ {
if (mode >= STBDS_HM_STRING) if (mode >= STBDS_HM_STRING)
return 0==strcmp((char *) key, * (char **) ((char *) a + elemsize*i)); return 0==strcmp((char *) key, * (char **) ((char *) a + elemsize*i + keyoffset));
else else
return 0==memcmp(key, (char *) a + elemsize*i, keysize); return 0==memcmp(key, (char *) a + elemsize*i + keyoffset, keysize);
} }
#define STBDS_HASH_TO_ARR(x,elemsize) ((char*) (x) - (elemsize)) #define STBDS_HASH_TO_ARR(x,elemsize) ((char*) (x) - (elemsize))