Skip to content

Commit cddd7f5

Browse files
andy31415andreilitvinbzbarsky-apple
authored
Update Constructor comments on PascalBuffer (project-chip#40459)
* Update pascalstring comments * Update src/app/persistence/PascalString.h Co-authored-by: Boris Zbarsky <[email protected]> * Update src/app/persistence/PascalString.h Co-authored-by: Boris Zbarsky <[email protected]> * Update src/app/persistence/PascalString.h Co-authored-by: Boris Zbarsky <[email protected]> * Update src/app/persistence/PascalString.h Co-authored-by: Boris Zbarsky <[email protected]> --------- Co-authored-by: Andrei Litvin <[email protected]> Co-authored-by: Boris Zbarsky <[email protected]>
1 parent 57fa745 commit cddd7f5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/app/persistence/PascalString.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,23 @@ class PascalBuffer
8686
PascalBuffer(PascalBuffer &&) = default;
8787
PascalBuffer(const PascalBuffer &) = default;
8888

89+
/// Interprets the given data as the pascal string content.
90+
///
91+
/// Note that this references the given data in place. Data lifetime must
92+
/// exceed the PascalBuffer lifetime.
8993
template <size_t N>
9094
PascalBuffer(T (&data)[N]) : mData(data), mMaxSize(N - PREFIX_LEN)
9195
{
9296
static_assert(N >= PREFIX_LEN);
9397
static_assert(N <= kInvalidLength);
9498
}
9599

96-
/// Allocates a pascal buffer of the given size.
100+
/// Uses an existing buffer for the pascal string, represented as a span.
101+
///
102+
/// The size of the span includes the prefix and must be at least PREFIX_LEN (this is NOT checked).
97103
///
98-
/// buffer_size includes the prefix and must be at least PREFIX_LEN.
104+
/// Note that this references the given buffer in place. The buffer that the span
105+
/// points to must have a lifetime that exceeds the PascalBuffer lifetime.
99106
PascalBuffer(Span<T> data) : mData(data.data()), mMaxSize(static_cast<LengthType>(data.size() - PREFIX_LEN)) {}
100107

101108
/// Returns the content of the pascal string.

0 commit comments

Comments
 (0)