ht.c revision 567aab801d6db09bae86914007066c88c08a6252
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * Copyright (C) 2016, 2018 Internet Systems Consortium, Inc. ("ISC")
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * This Source Code Form is subject to the terms of the Mozilla Public
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * License, v. 2.0. If a copy of the MPL was not distributed with this
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * file, You can obtain one at http://mozilla.org/MPL/2.0/.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt#define ISC_HT_VALID(ht) ISC_MAGIC_VALID(ht, ISC_HT_MAGIC)
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt unsigned int magic;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt unsigned int count;
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrewsisc_ht_init(isc_ht_t **htp, isc_mem_t *mctx, isc_uint8_t bits) {
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews REQUIRE(bits >= 1 && bits <= (sizeof(size_t)*8 - 1));
0cfb24736841b3e98bb25853229a0efabab88bddEvan Hunt ht->table = isc_mem_get(ht->mctx, ht->size * sizeof(isc_ht_node_t*));
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews isc_mem_putanddetach(&ht->mctx, ht, sizeof(struct isc_ht));
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt isc_mem_put(ht->mctx, ht->table, ht->size * sizeof(isc_ht_node_t*));
9c03f13e18c1b0c32f62391a17300378605bbc7bEvan Hunt isc_mem_putanddetach(&ht->mctx, ht, sizeof(struct isc_ht));
5a75f61dd413720c16d229b24ebba6bd6ecdb738Evan Hunt hash = isc_hash_function(key, keysize, ISC_TRUE, NULL);
af850c4120c5bee9462de4def85d0b4c1b583963Mark Andrews node = isc_mem_get(ht->mctx, offsetof(isc_ht_node_t, key) + keysize);
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Huntisc_ht_find(const isc_ht_t *ht, const unsigned char *key,
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt hash = isc_hash_function(key, keysize, ISC_TRUE, NULL);
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Huntisc_ht_delete(isc_ht_t *ht, const unsigned char *key, isc_uint32_t keysize) {
161e803a5608956271d8120be37a1b383d14b647Mark Andrews hash = isc_hash_function(key, keysize, ISC_TRUE, NULL);
return (ISC_R_NOTFOUND);
return (ISC_R_NOMEMORY);
it->i = 0;
return (ISC_R_SUCCESS);
it->i = 0;
it->i++;
return (ISC_R_NOMORE);
return (ISC_R_SUCCESS);
it->i++;
return (ISC_R_NOMORE);
return (ISC_R_SUCCESS);
it->i++;
NULL);
return (result);