4 Copyright 2008-2012 Michel Pollet <buserror@gmail.com>
6 This file is part of simavr.
8 simavr is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 simavr is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with simavr. If not, see <http://www.gnu.org/licenses/>.
26 str_hash_init(str_hash_p h)
28 memset(h, 0, sizeof(*h));
37 uint16_t hv = str_hash(k);
38 hashval_array_p bin = &h->bin[hv & (STR_HASH_SIZE-1)];
39 int inserti = bin->count;
41 for (int i = 0; i < bin->count; i++)
42 if (bin->e[i].key->hash >= hv) {
46 str_hashval_t n = { .key = str_dup(k), .val = v };
47 hashval_array_insert(bin, inserti, &n, 1);
56 uint16_t hv = str_hash(k);
57 hashval_array_p bin = &h->bin[hv & (STR_HASH_SIZE-1)];
59 for (int i = 0; i < bin->count; i++) {
60 uint16_t h = bin->e[i].key->hash;
61 if (h == hv && !str_cmp(k, bin->e[i].key))