pool.h
Go to the documentation of this file.
1 /* Copyright (c) 2016, Google Inc.
2  *
3  * Permission to use, copy, modify, and/or distribute this software for any
4  * purpose with or without fee is hereby granted, provided that the above
5  * copyright notice and this permission notice appear in all copies.
6  *
7  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14 
15 #ifndef OPENSSL_HEADER_POOL_H
16 #define OPENSSL_HEADER_POOL_H
17 
18 #include <openssl/base.h>
19 
20 #include <openssl/stack.h>
21 
22 #if defined(__cplusplus)
23 extern "C" {
24 #endif
25 
26 
27 // Buffers and buffer pools.
28 //
29 // |CRYPTO_BUFFER|s are simply reference-counted blobs. A |CRYPTO_BUFFER_POOL|
30 // is an intern table for |CRYPTO_BUFFER|s. This allows for a single copy of a
31 // given blob to be kept in memory and referenced from multiple places.
32 
33 
35 
36 // CRYPTO_BUFFER_POOL_new returns a freshly allocated |CRYPTO_BUFFER_POOL| or
37 // NULL on error.
39 
40 // CRYPTO_BUFFER_POOL_free frees |pool|, which must be empty.
42 
43 // CRYPTO_BUFFER_new returns a |CRYPTO_BUFFER| containing a copy of |data|, or
44 // else NULL on error. If |pool| is not NULL then the returned value may be a
45 // reference to a previously existing |CRYPTO_BUFFER| that contained the same
46 // data. Otherwise, the returned, fresh |CRYPTO_BUFFER| will be added to the
47 // pool.
50 
51 // CRYPTO_BUFFER_alloc creates an unpooled |CRYPTO_BUFFER| of the given size and
52 // writes the underlying data pointer to |*out_data|. It returns NULL on error.
53 //
54 // After calling this function, |len| bytes of contents must be written to
55 // |out_data| before passing the returned pointer to any other BoringSSL
56 // functions. Once initialized, the |CRYPTO_BUFFER| should be treated as
57 // immutable.
59  size_t len);
60 
61 // CRYPTO_BUFFER_new_from_CBS acts the same as |CRYPTO_BUFFER_new|.
63  const CBS *cbs, CRYPTO_BUFFER_POOL *pool);
64 
65 // CRYPTO_BUFFER_new_from_static_data_unsafe behaves like |CRYPTO_BUFFER_new|
66 // but does not copy |data|. |data| must be immutable and last for the lifetime
67 // of the address space.
69  const uint8_t *data, size_t len, CRYPTO_BUFFER_POOL *pool);
70 
71 // CRYPTO_BUFFER_free decrements the reference count of |buf|. If there are no
72 // other references, or if the only remaining reference is from a pool, then
73 // |buf| will be freed.
75 
76 // CRYPTO_BUFFER_up_ref increments the reference count of |buf| and returns
77 // one.
79 
80 // CRYPTO_BUFFER_data returns a pointer to the data contained in |buf|.
82 
83 // CRYPTO_BUFFER_len returns the length, in bytes, of the data contained in
84 // |buf|.
86 
87 // CRYPTO_BUFFER_init_CBS initialises |out| to point at the data from |buf|.
89 
90 
91 #if defined(__cplusplus)
92 } // extern C
93 
94 extern "C++" {
95 
97 
101 
103 
104 } // extern C++
105 
106 #endif
107 
108 #endif // OPENSSL_HEADER_POOL_H
gen_build_yaml.out
dictionary out
Definition: src/benchmark/gen_build_yaml.py:24
cbs_st
Definition: bytestring.h:39
CRYPTO_BUFFER_len
OPENSSL_EXPORT size_t CRYPTO_BUFFER_len(const CRYPTO_BUFFER *buf)
Definition: pool.c:251
CRYPTO_BUFFER_alloc
OPENSSL_EXPORT CRYPTO_BUFFER * CRYPTO_BUFFER_alloc(uint8_t **out_data, size_t len)
Definition: pool.c:165
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
CRYPTO_BUFFER_new_from_static_data_unsafe
OPENSSL_EXPORT CRYPTO_BUFFER * CRYPTO_BUFFER_new_from_static_data_unsafe(const uint8_t *data, size_t len, CRYPTO_BUFFER_POOL *pool)
Definition: pool.c:189
CRYPTO_BUFFER_POOL_free
OPENSSL_EXPORT void CRYPTO_BUFFER_POOL_free(CRYPTO_BUFFER_POOL *pool)
Definition: pool.c:57
crypto_buffer_st
Definition: third_party/boringssl-with-bazel/src/crypto/pool/internal.h:31
cbs
const CBS * cbs
Definition: third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h:107
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
CRYPTO_BUFFER_new_from_CBS
OPENSSL_EXPORT CRYPTO_BUFFER * CRYPTO_BUFFER_new_from_CBS(const CBS *cbs, CRYPTO_BUFFER_POOL *pool)
Definition: pool.c:184
base.h
CRYPTO_BUFFER_up_ref
OPENSSL_EXPORT int CRYPTO_BUFFER_up_ref(CRYPTO_BUFFER *buf)
Definition: pool.c:236
BORINGSSL_MAKE_UP_REF
#define BORINGSSL_MAKE_UP_REF(type, up_ref_func)
Definition: base.h:507
BSSL_NAMESPACE_END
#define BSSL_NAMESPACE_END
Definition: base.h:480
CRYPTO_BUFFER_POOL_new
OPENSSL_EXPORT CRYPTO_BUFFER_POOL * CRYPTO_BUFFER_POOL_new(void)
Definition: pool.c:39
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
DEFINE_STACK_OF
#define DEFINE_STACK_OF(type)
Definition: stack.h:409
CRYPTO_BUFFER_init_CBS
OPENSSL_EXPORT void CRYPTO_BUFFER_init_CBS(const CRYPTO_BUFFER *buf, CBS *out)
Definition: pool.c:255
BSSL_NAMESPACE_BEGIN
Definition: trust_token_test.cc:45
CRYPTO_BUFFER_new
OPENSSL_EXPORT CRYPTO_BUFFER * CRYPTO_BUFFER_new(const uint8_t *data, size_t len, CRYPTO_BUFFER_POOL *pool)
Definition: pool.c:160
OPENSSL_EXPORT
#define OPENSSL_EXPORT
Definition: base.h:222
BORINGSSL_MAKE_DELETER
#define BORINGSSL_MAKE_DELETER(type, deleter)
Definition: base.h:506
crypto_buffer_pool_st
Definition: third_party/boringssl-with-bazel/src/crypto/pool/internal.h:39
pool
InternalDescriptorPool * pool
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:807
CRYPTO_BUFFER_data
const OPENSSL_EXPORT uint8_t * CRYPTO_BUFFER_data(const CRYPTO_BUFFER *buf)
Definition: pool.c:247
len
int len
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46
stack.h
CRYPTO_BUFFER_free
OPENSSL_EXPORT void CRYPTO_BUFFER_free(CRYPTO_BUFFER *buf)
Definition: pool.c:194


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:44