Lines Matching refs:hctx

148 	isc_hash_t *hctx;
166 hctx = isc_mem_get(mctx, sizeof(isc_hash_t));
167 if (hctx == NULL)
180 result = isc_mutex_init(&hctx->lock);
187 hctx->magic = HASH_MAGIC;
188 hctx->mctx = NULL;
189 isc_mem_attach(mctx, &hctx->mctx);
190 hctx->initialized = ISC_FALSE;
191 result = isc_refcount_init(&hctx->refcnt, 1);
194 hctx->entropy = NULL;
195 hctx->limit = limit;
196 hctx->vectorlen = vlen;
197 hctx->rndvector = rv;
200 isc_entropy_attach(entropy, &hctx->entropy);
202 *hctxp = hctx;
206 DESTROYLOCK(&hctx->lock);
208 isc_mem_put(mctx, hctx, sizeof(isc_hash_t));
240 isc_hash_ctxinit(isc_hash_t *hctx) {
243 LOCK(&hctx->lock);
245 if (hctx->initialized == ISC_TRUE)
248 if (hctx->entropy) {
249 result = isc_entropy_getdata(hctx->entropy,
250 hctx->rndvector, hctx->vectorlen,
258 p = (unsigned char *)hctx->rndvector;
259 for (i = 0; i < hctx->vectorlen; i += copylen, p += copylen) {
261 if (i + sizeof(pr) <= hctx->vectorlen)
264 copylen = hctx->vectorlen - i;
268 INSIST(p == (unsigned char *)hctx->rndvector +
269 hctx->vectorlen);
272 hctx->initialized = ISC_TRUE;
275 UNLOCK(&hctx->lock);
286 isc_hash_ctxattach(isc_hash_t *hctx, isc_hash_t **hctxp) {
287 REQUIRE(VALID_HASH(hctx));
290 isc_refcount_increment(&hctx->refcnt, NULL);
291 *hctxp = hctx;
296 isc_hash_t *hctx;
300 hctx = *hctxp;
303 LOCK(&hctx->lock);
305 isc_refcount_destroy(&hctx->refcnt);
307 mctx = hctx->mctx;
308 if (hctx->entropy != NULL)
309 isc_entropy_detach(&hctx->entropy);
310 if (hctx->rndvector != NULL)
311 isc_mem_put(mctx, hctx->rndvector, hctx->vectorlen);
313 UNLOCK(&hctx->lock);
315 DESTROYLOCK(&hctx->lock);
317 memset(hctx, 0, sizeof(isc_hash_t));
318 isc_mem_put(mctx, hctx, sizeof(isc_hash_t));
324 isc_hash_t *hctx;
328 hctx = *hctxp;
330 isc_refcount_decrement(&hctx->refcnt, &refs);
332 destroy(&hctx);
350 hash_calc(isc_hash_t *hctx, const unsigned char *key, unsigned int keylen,
354 hash_random_t *p = hctx->rndvector;
358 if (hctx->initialized == ISC_FALSE)
359 isc_hash_ctxinit(hctx);
375 isc_hash_ctxcalc(isc_hash_t *hctx, const unsigned char *key,
378 REQUIRE(hctx != NULL && VALID_HASH(hctx));
379 REQUIRE(keylen <= hctx->limit);
381 return (hash_calc(hctx, key, keylen, case_sensitive));