Lines Matching refs:hctx

136 	isc_hash_t *hctx;
154 hctx = isc_mem_get(mctx, sizeof(isc_hash_t));
155 if (hctx == NULL)
168 result = isc_mutex_init(&hctx->lock);
175 hctx->magic = HASH_MAGIC;
176 hctx->mctx = NULL;
177 isc_mem_attach(mctx, &hctx->mctx);
178 hctx->initialized = ISC_FALSE;
179 result = isc_refcount_init(&hctx->refcnt, 1);
182 hctx->entropy = NULL;
183 hctx->limit = limit;
184 hctx->vectorlen = vlen;
185 hctx->rndvector = rv;
188 isc_entropy_attach(entropy, &hctx->entropy);
190 *hctxp = hctx;
194 DESTROYLOCK(&hctx->lock);
196 isc_mem_put(mctx, hctx, sizeof(isc_hash_t));
229 isc_hash_ctxinit(isc_hash_t *hctx) {
230 LOCK(&hctx->lock);
232 if (hctx->initialized == ISC_TRUE)
235 if (hctx->entropy != NULL) {
238 result = isc_entropy_getdata(hctx->entropy,
239 hctx->rndvector,
240 (unsigned int)hctx->vectorlen,
248 p = (unsigned char *)hctx->rndvector;
249 for (i = 0; i < hctx->vectorlen; i += copylen, p += copylen) {
251 if (i + sizeof(pr) <= hctx->vectorlen)
254 copylen = hctx->vectorlen - i;
258 INSIST(p == (unsigned char *)hctx->rndvector +
259 hctx->vectorlen);
262 hctx->initialized = ISC_TRUE;
265 UNLOCK(&hctx->lock);
276 isc_hash_ctxattach(isc_hash_t *hctx, isc_hash_t **hctxp) {
277 REQUIRE(VALID_HASH(hctx));
280 isc_refcount_increment(&hctx->refcnt, NULL);
281 *hctxp = hctx;
286 isc_hash_t *hctx;
290 hctx = *hctxp;
293 LOCK(&hctx->lock);
295 isc_refcount_destroy(&hctx->refcnt);
297 mctx = hctx->mctx;
298 if (hctx->entropy != NULL)
299 isc_entropy_detach(&hctx->entropy);
300 if (hctx->rndvector != NULL)
301 isc_mem_put(mctx, hctx->rndvector, hctx->vectorlen);
303 UNLOCK(&hctx->lock);
305 DESTROYLOCK(&hctx->lock);
307 memset(hctx, 0, sizeof(isc_hash_t));
308 isc_mem_put(mctx, hctx, sizeof(isc_hash_t));
314 isc_hash_t *hctx;
318 hctx = *hctxp;
320 isc_refcount_decrement(&hctx->refcnt, &refs);
322 destroy(&hctx);
340 hash_calc(isc_hash_t *hctx, const unsigned char *key, unsigned int keylen,
344 hash_random_t *p = hctx->rndvector;
348 if (hctx->initialized == ISC_FALSE)
349 isc_hash_ctxinit(hctx);
365 isc_hash_ctxcalc(isc_hash_t *hctx, const unsigned char *key,
368 REQUIRE(hctx != NULL && VALID_HASH(hctx));
369 REQUIRE(keylen <= hctx->limit);
371 return (hash_calc(hctx, key, keylen, case_sensitive));