From 63e4ada98c0e7feff1eb00d55a4399599ae13d7b Mon Sep 17 00:00:00 2001 From: Macoy Madson Date: Mon, 31 May 2021 19:51:39 -0700 Subject: [PATCH 1/2] Fix temp_key being stale on key re-insert See issue #992 and pull request #993. --- stb_ds.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stb_ds.h b/stb_ds.h index d1e0c75..a193f1a 100644 --- a/stb_ds.h +++ b/stb_ds.h @@ -1378,6 +1378,8 @@ void *stbds_hmput_key(void *a, size_t elemsize, void *key, size_t keysize, int m if (bucket->hash[i] == hash) { if (stbds_is_key_equal(raw_a, elemsize, key, keysize, keyoffset, mode, bucket->index[i])) { stbds_temp(a) = bucket->index[i]; + if (mode >= STBDS_HM_STRING) + stbds_temp_key(a) = * (char **) ((char *) raw_a + elemsize*bucket->index[i] + keyoffset); return STBDS_ARR_TO_HASH(a,elemsize); } } else if (bucket->hash[i] == 0) { From e97a95c0c1a5a134f60d43dd0ac4c3152a0a40ca Mon Sep 17 00:00:00 2001 From: Macoy Madson Date: Mon, 31 May 2021 19:53:09 -0700 Subject: [PATCH 2/2] Added Macoy Madson to contributors --- stb_ds.h | 1 + 1 file changed, 1 insertion(+) diff --git a/stb_ds.h b/stb_ds.h index a193f1a..b81badc 100644 --- a/stb_ds.h +++ b/stb_ds.h @@ -379,6 +379,7 @@ CREDITS Andreas Molzer github:hashitaku github:srdjanstipic + Macoy Madson */ #ifdef STBDS_UNIT_TESTS