From: Peter Johnson Date: Wed, 1 Aug 2007 05:14:53 +0000 (-0000) Subject: HAMT: Update stored key when building tree downwards from identical keys. X-Git-Tag: v0.6.2~8^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d7b386bababb50dd54b649cdcd61324e3472e636;p=yasm HAMT: Update stored key when building tree downwards from identical keys. Not doing this could cause us to lose an entry if the tree is deep enough that we need to rehash the keys as we're moving downward. Reported by: Stefan Sellmer svn path=/trunk/yasm/; revision=1905 --- diff --git a/libyasm/hamt.c b/libyasm/hamt.c index 033a48ac..ceee28f7 100644 --- a/libyasm/hamt.c +++ b/libyasm/hamt.c @@ -281,7 +281,8 @@ HAMT_insert(HAMT *hamt, const char *str, void *data, int *replace, * downward. */ newnodes = yasm_xmalloc(sizeof(HAMTNode)); - newnodes[0] = *node; /* structure copy */ + newnodes[0].BitMapKey = key2; + newnodes[0].BaseValue = node->BaseValue; node->BitMapKey = 1<BaseValue; newnodes[1].BitMapKey = key; SetValue(hamt, &newnodes[1], entry); } else { newnodes[0].BitMapKey = key; SetValue(hamt, &newnodes[0], entry); - newnodes[1] = *node; /* structure copy */ + newnodes[1].BitMapKey = key2; + newnodes[1].BaseValue = node->BaseValue; } /* Set bits in bitmap corresponding to keys */