File tree 1 file changed +14
-0
lines changed
1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -390,4 +390,18 @@ inline CHIP_ERROR CopyCharSpanToMutableCharSpan(CharSpan cspan_to_copy, MutableC
390
390
return CHIP_NO_ERROR;
391
391
}
392
392
393
+ /* *
394
+ * Copies a CharSpan into a MutableCharSpan.
395
+ * If the span_to_copy does not fit in out_span, span_to_copy is truncated to fit in out_span.
396
+ * @param span_to_copy The CharSpan to copy.
397
+ * @param out_span The MutableCharSpan in which span_to_copy is to be copied.
398
+ */
399
+ inline void CopyCharSpanToMutableCharSpanWithTruncation (CharSpan span_to_copy, MutableCharSpan & out_span)
400
+ {
401
+ size_t size_to_copy = std::min (span_to_copy.size (), out_span.size ());
402
+
403
+ memcpy (out_span.data (), span_to_copy.data (), size_to_copy);
404
+ out_span.reduce_size (size_to_copy);
405
+ }
406
+
393
407
} // namespace chip
You can’t perform that action at this time.
0 commit comments