@@ -182,9 +182,14 @@ used freely without special cleanup conventions.
182
182
183
183
When working with allocated objects, it is important to think about * ownership*
184
184
of each object, or what code is responsible for releasing it. This matches the
185
- corresponding notion in higher-level languages like C++ and Rust. Ownership
186
- applies to both uniquely-owned types and reference-counted types. For the
187
- latter, ownership means the code is responsible for releasing one reference.
185
+ corresponding notion in higher-level languages like C++ and Rust.
186
+
187
+ Ownership applies to both uniquely-owned types and reference-counted types. For
188
+ the latter, ownership means the code is responsible for releasing one
189
+ reference. Note a * reference* in BoringSSL refers to an increment (and eventual
190
+ decrement) of an object's reference count, not ` T& ` in C++. Thus, to "take a
191
+ reference" means to increment the reference count and take ownership of
192
+ decrementing it.
188
193
189
194
As BoringSSL's APIs are primarily in C, ownership and lifetime obligations are
190
195
not rigorously annotated in the type signatures or checked at compile-time.
@@ -217,12 +222,12 @@ sooner on state change in the parent object.
217
222
If documented to output a * newly-allocated* object or a * reference* or * copy* of
218
223
one, the caller is responsible for releasing the object when it is done.
219
224
220
- By convention, functions named ` get0 ` return non-owning pointers. Functions name
221
- ` new ` or ` get1 ` return owning pointers. Functions named ` set0 ` take ownership of
222
- arguments. Functions named ` set1 ` do not. They typically take a reference or
223
- make a copy internally. These names originally referred to the effect on a
224
- reference count, but the convention applies equally to non-reference-counted
225
- types.
225
+ By convention, functions named ` get0 ` return non-owning pointers. Functions
226
+ named ` new ` or ` get1 ` return owning pointers. Functions named ` set0 ` take
227
+ ownership of arguments. Functions named ` set1 ` do not. They typically take a
228
+ reference or make a copy internally. These names originally referred to the
229
+ effect on a reference count, but the convention applies equally to
230
+ non-reference-counted types.
226
231
227
232
API documentation may also describe more complex obligations. For instance, an
228
233
object may borrow a pointer for longer than the duration of a single function
0 commit comments