Lines Matching refs:pool
31 return (uint32_t)SIPHASH_24(buf->pool->hash_key, buf->data, buf->len); in CRYPTO_BUFFER_hash()
36 assert(a->pool != NULL); in CRYPTO_BUFFER_cmp()
37 assert(a->pool == b->pool); in CRYPTO_BUFFER_cmp()
45 CRYPTO_BUFFER_POOL *pool = OPENSSL_malloc(sizeof(CRYPTO_BUFFER_POOL)); in CRYPTO_BUFFER_POOL_new() local
46 if (pool == NULL) { in CRYPTO_BUFFER_POOL_new()
50 OPENSSL_memset(pool, 0, sizeof(CRYPTO_BUFFER_POOL)); in CRYPTO_BUFFER_POOL_new()
51 pool->bufs = lh_CRYPTO_BUFFER_new(CRYPTO_BUFFER_hash, CRYPTO_BUFFER_cmp); in CRYPTO_BUFFER_POOL_new()
52 if (pool->bufs == NULL) { in CRYPTO_BUFFER_POOL_new()
53 OPENSSL_free(pool); in CRYPTO_BUFFER_POOL_new()
57 CRYPTO_MUTEX_init(&pool->lock); in CRYPTO_BUFFER_POOL_new()
58 RAND_bytes((uint8_t *)&pool->hash_key, sizeof(pool->hash_key)); in CRYPTO_BUFFER_POOL_new()
60 return pool; in CRYPTO_BUFFER_POOL_new()
63 void CRYPTO_BUFFER_POOL_free(CRYPTO_BUFFER_POOL *pool) { in CRYPTO_BUFFER_POOL_free() argument
64 if (pool == NULL) { in CRYPTO_BUFFER_POOL_free()
69 CRYPTO_MUTEX_lock_write(&pool->lock); in CRYPTO_BUFFER_POOL_free()
70 assert(lh_CRYPTO_BUFFER_num_items(pool->bufs) == 0); in CRYPTO_BUFFER_POOL_free()
71 CRYPTO_MUTEX_unlock_write(&pool->lock); in CRYPTO_BUFFER_POOL_free()
74 lh_CRYPTO_BUFFER_free(pool->bufs); in CRYPTO_BUFFER_POOL_free()
75 CRYPTO_MUTEX_cleanup(&pool->lock); in CRYPTO_BUFFER_POOL_free()
76 OPENSSL_free(pool); in CRYPTO_BUFFER_POOL_free()
88 CRYPTO_BUFFER_POOL *pool) { in crypto_buffer_new() argument
89 if (pool != NULL) { in crypto_buffer_new()
93 tmp.pool = pool; in crypto_buffer_new()
95 CRYPTO_MUTEX_lock_read(&pool->lock); in crypto_buffer_new()
96 CRYPTO_BUFFER *duplicate = lh_CRYPTO_BUFFER_retrieve(pool->bufs, &tmp); in crypto_buffer_new()
105 CRYPTO_MUTEX_unlock_read(&pool->lock); in crypto_buffer_new()
132 if (pool == NULL) { in crypto_buffer_new()
136 buf->pool = pool; in crypto_buffer_new()
138 CRYPTO_MUTEX_lock_write(&pool->lock); in crypto_buffer_new()
139 CRYPTO_BUFFER *duplicate = lh_CRYPTO_BUFFER_retrieve(pool->bufs, buf); in crypto_buffer_new()
148 inserted = lh_CRYPTO_BUFFER_insert(pool->bufs, &old, buf); in crypto_buffer_new()
155 CRYPTO_MUTEX_unlock_write(&pool->lock); in crypto_buffer_new()
168 CRYPTO_BUFFER_POOL *pool) { in CRYPTO_BUFFER_new() argument
169 return crypto_buffer_new(data, len, /*data_is_static=*/0, pool); in CRYPTO_BUFFER_new()
192 CRYPTO_BUFFER_POOL *pool) { in CRYPTO_BUFFER_new_from_CBS() argument
193 return CRYPTO_BUFFER_new(CBS_data(cbs), CBS_len(cbs), pool); in CRYPTO_BUFFER_new_from_CBS()
197 const uint8_t *data, size_t len, CRYPTO_BUFFER_POOL *pool) { in CRYPTO_BUFFER_new_from_static_data_unsafe() argument
198 return crypto_buffer_new(data, len, /*data_is_static=*/1, pool); in CRYPTO_BUFFER_new_from_static_data_unsafe()
206 CRYPTO_BUFFER_POOL *const pool = buf->pool; in CRYPTO_BUFFER_free() local
207 if (pool == NULL) { in CRYPTO_BUFFER_free()
218 CRYPTO_MUTEX_lock_write(&pool->lock); in CRYPTO_BUFFER_free()
220 CRYPTO_MUTEX_unlock_write(&buf->pool->lock); in CRYPTO_BUFFER_free()
232 CRYPTO_BUFFER *found = lh_CRYPTO_BUFFER_retrieve(pool->bufs, buf); in CRYPTO_BUFFER_free()
234 found = lh_CRYPTO_BUFFER_delete(pool->bufs, buf); in CRYPTO_BUFFER_free()
239 CRYPTO_MUTEX_unlock_write(&buf->pool->lock); in CRYPTO_BUFFER_free()