Lines Matching full:pool
15 #include <openssl/pool.h>
42 CRYPTO_BUFFER_POOL *pool = OPENSSL_malloc(sizeof(CRYPTO_BUFFER_POOL)); in CRYPTO_BUFFER_POOL_new() local
43 if (pool == NULL) { in CRYPTO_BUFFER_POOL_new()
47 OPENSSL_memset(pool, 0, sizeof(CRYPTO_BUFFER_POOL)); in CRYPTO_BUFFER_POOL_new()
48 pool->bufs = lh_CRYPTO_BUFFER_new(CRYPTO_BUFFER_hash, CRYPTO_BUFFER_cmp); in CRYPTO_BUFFER_POOL_new()
49 if (pool->bufs == NULL) { in CRYPTO_BUFFER_POOL_new()
50 OPENSSL_free(pool); in CRYPTO_BUFFER_POOL_new()
54 CRYPTO_MUTEX_init(&pool->lock); in CRYPTO_BUFFER_POOL_new()
56 return pool; in CRYPTO_BUFFER_POOL_new()
59 void CRYPTO_BUFFER_POOL_free(CRYPTO_BUFFER_POOL *pool) { in CRYPTO_BUFFER_POOL_free() argument
60 if (pool == NULL) { in CRYPTO_BUFFER_POOL_free()
65 CRYPTO_MUTEX_lock_write(&pool->lock); in CRYPTO_BUFFER_POOL_free()
66 assert(lh_CRYPTO_BUFFER_num_items(pool->bufs) == 0); in CRYPTO_BUFFER_POOL_free()
67 CRYPTO_MUTEX_unlock_write(&pool->lock); in CRYPTO_BUFFER_POOL_free()
70 lh_CRYPTO_BUFFER_free(pool->bufs); in CRYPTO_BUFFER_POOL_free()
71 CRYPTO_MUTEX_cleanup(&pool->lock); in CRYPTO_BUFFER_POOL_free()
72 OPENSSL_free(pool); in CRYPTO_BUFFER_POOL_free()
76 CRYPTO_BUFFER_POOL *pool) { in CRYPTO_BUFFER_new() argument
77 if (pool != NULL) { in CRYPTO_BUFFER_new()
82 CRYPTO_MUTEX_lock_read(&pool->lock); in CRYPTO_BUFFER_new()
84 lh_CRYPTO_BUFFER_retrieve(pool->bufs, &tmp); in CRYPTO_BUFFER_new()
88 CRYPTO_MUTEX_unlock_read(&pool->lock); in CRYPTO_BUFFER_new()
110 if (pool == NULL) { in CRYPTO_BUFFER_new()
114 buf->pool = pool; in CRYPTO_BUFFER_new()
116 CRYPTO_MUTEX_lock_write(&pool->lock); in CRYPTO_BUFFER_new()
117 CRYPTO_BUFFER *duplicate = lh_CRYPTO_BUFFER_retrieve(pool->bufs, buf); in CRYPTO_BUFFER_new()
121 inserted = lh_CRYPTO_BUFFER_insert(pool->bufs, &old, buf); in CRYPTO_BUFFER_new()
126 CRYPTO_MUTEX_unlock_write(&pool->lock); in CRYPTO_BUFFER_new()
129 // We raced to insert |buf| into the pool and lost, or else there was an in CRYPTO_BUFFER_new()
158 CRYPTO_BUFFER* CRYPTO_BUFFER_new_from_CBS(CBS *cbs, CRYPTO_BUFFER_POOL *pool) { in CRYPTO_BUFFER_new_from_CBS() argument
159 return CRYPTO_BUFFER_new(CBS_data(cbs), CBS_len(cbs), pool); in CRYPTO_BUFFER_new_from_CBS()
167 CRYPTO_BUFFER_POOL *const pool = buf->pool; in CRYPTO_BUFFER_free() local
168 if (pool == NULL) { in CRYPTO_BUFFER_free()
171 // from any pool to this buffer and thus we are able to free this in CRYPTO_BUFFER_free()
180 CRYPTO_MUTEX_lock_write(&pool->lock); in CRYPTO_BUFFER_free()
182 CRYPTO_MUTEX_unlock_write(&buf->pool->lock); in CRYPTO_BUFFER_free()
186 // We have an exclusive lock on the pool, therefore no concurrent lookups can in CRYPTO_BUFFER_free()
190 void *found = lh_CRYPTO_BUFFER_delete(pool->bufs, buf); in CRYPTO_BUFFER_free()
194 CRYPTO_MUTEX_unlock_write(&buf->pool->lock); in CRYPTO_BUFFER_free()
200 // This is safe in the case that |buf->pool| is NULL because it's just in CRYPTO_BUFFER_up_ref()
203 // This is also safe if |buf->pool| is non-NULL because, if it were racing in CRYPTO_BUFFER_up_ref()