pool.h

All headers

Buffers and buffer pools.

CRYPTO_BUFFERs are simply reference-counted blobs. A CRYPTO_BUFFER_POOL is an intern table for CRYPTO_BUFFERs. This allows for a single copy of a given blob to be kept in memory and referenced from multiple places.

  1. CRYPTO_BUFFER_POOL_new
  2. CRYPTO_BUFFER_POOL_free
  3. CRYPTO_BUFFER_new
  4. CRYPTO_BUFFER_new_from_CBS
  5. CRYPTO_BUFFER_free
  6. CRYPTO_BUFFER_up_ref
  7. CRYPTO_BUFFER_data
  8. CRYPTO_BUFFER_len
  9. CRYPTO_BUFFER_init_CBS
DEFINE_STACK_OF(CRYPTO_BUFFER)

CRYPTO_BUFFER_POOL_new returns a freshly allocated CRYPTO_BUFFER_POOL or NULL on error.

OPENSSL_EXPORT CRYPTO_BUFFER_POOL* CRYPTO_BUFFER_POOL_new(void);

CRYPTO_BUFFER_POOL_free frees pool, which must be empty.

OPENSSL_EXPORT void CRYPTO_BUFFER_POOL_free(CRYPTO_BUFFER_POOL *pool);

CRYPTO_BUFFER_new returns a CRYPTO_BUFFER containing a copy of data, or else NULL on error. If pool is not NULL then the returned value may be a reference to a previously existing CRYPTO_BUFFER that contained the same data. Otherwise, the returned, fresh CRYPTO_BUFFER will be added to the pool.

OPENSSL_EXPORT CRYPTO_BUFFER *CRYPTO_BUFFER_new(const uint8_t *data, size_t len,
                                                CRYPTO_BUFFER_POOL *pool);

CRYPTO_BUFFER_new_from_CBS acts the same as CRYPTO_BUFFER_new.

OPENSSL_EXPORT CRYPTO_BUFFER *CRYPTO_BUFFER_new_from_CBS(
    CBS *cbs, CRYPTO_BUFFER_POOL *pool);

CRYPTO_BUFFER_free decrements the reference count of buf. If there are no other references, or if the only remaining reference is from a pool, then buf will be freed.

OPENSSL_EXPORT void CRYPTO_BUFFER_free(CRYPTO_BUFFER *buf);

CRYPTO_BUFFER_up_ref increments the reference count of buf and returns one.

OPENSSL_EXPORT int CRYPTO_BUFFER_up_ref(CRYPTO_BUFFER *buf);

CRYPTO_BUFFER_data returns a pointer to the data contained in buf.

OPENSSL_EXPORT const uint8_t *CRYPTO_BUFFER_data(const CRYPTO_BUFFER *buf);

CRYPTO_BUFFER_len returns the length, in bytes, of the data contained in buf.

OPENSSL_EXPORT size_t CRYPTO_BUFFER_len(const CRYPTO_BUFFER *buf);

CRYPTO_BUFFER_init_CBS initialises out to point at the data from buf.

OPENSSL_EXPORT void CRYPTO_BUFFER_init_CBS(const CRYPTO_BUFFER *buf, CBS *out);