Lines Matching refs: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;
199 isc_entropy_attach(entropy, &hctx->entropy);
204 *hctxp = hctx;
208 DESTROYLOCK(&hctx->lock);
210 isc_mem_put(mctx, hctx, sizeof(isc_hash_t));
242 isc_hash_ctxinit(isc_hash_t *hctx) {
243 LOCK(&hctx->lock);
245 if (hctx->initialized == ISC_TRUE)
248 if (hctx->entropy) {
252 result = isc_entropy_getdata(hctx->entropy,
253 hctx->rndvector, hctx->vectorlen,
264 p = (unsigned char *)hctx->rndvector;
265 for (i = 0; i < hctx->vectorlen; i += copylen, p += copylen) {
267 if (i + sizeof(pr) <= hctx->vectorlen)
270 copylen = hctx->vectorlen - i;
274 INSIST(p == (unsigned char *)hctx->rndvector +
275 hctx->vectorlen);
278 hctx->initialized = ISC_TRUE;
281 UNLOCK(&hctx->lock);
292 isc_hash_ctxattach(isc_hash_t *hctx, isc_hash_t **hctxp) {
293 REQUIRE(VALID_HASH(hctx));
296 isc_refcount_increment(&hctx->refcnt, NULL);
297 *hctxp = hctx;
302 isc_hash_t *hctx;
307 hctx = *hctxp;
310 LOCK(&hctx->lock);
312 isc_refcount_destroy(&hctx->refcnt);
314 mctx = hctx->mctx;
316 if (hctx->entropy != NULL)
317 isc_entropy_detach(&hctx->entropy);
319 if (hctx->rndvector != NULL)
320 isc_mem_put(mctx, hctx->rndvector, hctx->vectorlen);
322 UNLOCK(&hctx->lock);
324 DESTROYLOCK(&hctx->lock);
326 memcpy(canary0, hctx + 1, sizeof(canary0));
327 memset(hctx, 0, sizeof(isc_hash_t));
328 memcpy(canary1, hctx + 1, sizeof(canary1));
330 isc_mem_put(mctx, hctx, sizeof(isc_hash_t));
336 isc_hash_t *hctx;
340 hctx = *hctxp;
342 isc_refcount_decrement(&hctx->refcnt, &refs);
344 destroy(&hctx);
362 hash_calc(isc_hash_t *hctx, const unsigned char *key, unsigned int keylen,
366 hash_random_t *p = hctx->rndvector;
370 if (hctx->initialized == ISC_FALSE)
371 isc_hash_ctxinit(hctx);
387 isc_hash_ctxcalc(isc_hash_t *hctx, const unsigned char *key,
390 REQUIRE(hctx != NULL && VALID_HASH(hctx));
391 REQUIRE(keylen <= hctx->limit);
393 return (hash_calc(hctx, key, keylen, case_sensitive));