src/hash_map.c

changeset 575
b05935945637
parent 574
d566bd3e6af8
child 630
ac5e7f789048
     1.1 --- a/src/hash_map.c	Fri Aug 12 16:48:59 2022 +0200
     1.2 +++ b/src/hash_map.c	Fri Aug 12 16:56:41 2022 +0200
     1.3 @@ -86,12 +86,12 @@
     1.4          elm = elm->next;
     1.5      }
     1.6  
     1.7 -    if (elm != NULL && elm->key.hash == hash) {
     1.8 +    if (elm != NULL && elm->key.hash == hash && elm->key.len == key.len &&
     1.9 +        memcmp(elm->key.data.obj, key.data.obj, key.len) == 0) {
    1.10          // overwrite existing element
    1.11          elm->data = value;
    1.12      } else {
    1.13 -        // insert new element
    1.14 -
    1.15 +        // allocate new element
    1.16          struct cx_hash_map_element_s *e = cxMalloc(allocator, sizeof(struct cx_hash_map_element_s));
    1.17          if (e == NULL) {
    1.18              return -1;

mercurial