Lines Matching defs:hctx

146 	isc_hash_t *hctx;
164 hctx = isc_mem_get(mctx, sizeof(isc_hash_t));
165 if (hctx == NULL)
178 result = isc_mutex_init(&hctx->lock);
185 hctx->magic = HASH_MAGIC;
186 hctx->mctx = NULL;
187 isc_mem_attach(mctx, &hctx->mctx);
188 hctx->initialized = ISC_FALSE;
189 result = isc_refcount_init(&hctx->refcnt, 1);
192 hctx->entropy = NULL;
193 hctx->limit = limit;
194 hctx->vectorlen = vlen;
195 hctx->rndvector = rv;
198 isc_entropy_attach(entropy, &hctx->entropy);
200 *hctxp = hctx;
204 DESTROYLOCK(&hctx->lock);
206 isc_mem_put(mctx, hctx, sizeof(isc_hash_t));
238 isc_hash_ctxinit(isc_hash_t *hctx) {
241 LOCK(&hctx->lock);
243 if (hctx->initialized == ISC_TRUE)
246 if (hctx->entropy) {
247 result = isc_entropy_getdata(hctx->entropy,
248 hctx->rndvector, hctx->vectorlen,
256 p = (unsigned char *)hctx->rndvector;
257 for (i = 0; i < hctx->vectorlen; i += copylen, p += copylen) {
259 if (i + sizeof(pr) <= hctx->vectorlen)
262 copylen = hctx->vectorlen - i;
266 INSIST(p == (unsigned char *)hctx->rndvector +
267 hctx->vectorlen);
270 hctx->initialized = ISC_TRUE;
273 UNLOCK(&hctx->lock);
284 isc_hash_ctxattach(isc_hash_t *hctx, isc_hash_t **hctxp) {
285 REQUIRE(VALID_HASH(hctx));
288 isc_refcount_increment(&hctx->refcnt, NULL);
289 *hctxp = hctx;
294 isc_hash_t *hctx;
298 hctx = *hctxp;
301 LOCK(&hctx->lock);
303 isc_refcount_destroy(&hctx->refcnt);
305 mctx = hctx->mctx;
306 if (hctx->entropy != NULL)
307 isc_entropy_detach(&hctx->entropy);
308 if (hctx->rndvector != NULL)
309 isc_mem_put(mctx, hctx->rndvector, hctx->vectorlen);
311 UNLOCK(&hctx->lock);
313 DESTROYLOCK(&hctx->lock);
315 memset(hctx, 0, sizeof(isc_hash_t));
316 isc_mem_put(mctx, hctx, sizeof(isc_hash_t));
322 isc_hash_t *hctx;
326 hctx = *hctxp;
328 isc_refcount_decrement(&hctx->refcnt, &refs);
330 destroy(&hctx);
348 hash_calc(isc_hash_t *hctx, const unsigned char *key, unsigned int keylen,
352 hash_random_t *p = hctx->rndvector;
356 if (hctx->initialized == ISC_FALSE)
357 isc_hash_ctxinit(hctx);
373 isc_hash_ctxcalc(isc_hash_t *hctx, const unsigned char *key,
376 REQUIRE(hctx != NULL && VALID_HASH(hctx));
377 REQUIRE(keylen <= hctx->limit);
379 return (hash_calc(hctx, key, keylen, case_sensitive));