Commit Graph

1 Commits

Author SHA1 Message Date
John Mulligan e5d1a53060 cutil: add SplitBuffer and SplitSparseBuffer helper functions
Add SplitBuffer and SplitSparseBuffer functions for extracting a list
of strings from a single buffer, typically returned in C code, from
a single Go buffer. The SplitBuffer variant will return empty strings
if multiple nulls are found in sequence, assuming that the C code
packs data between on single null byte (expect the final byte).
The SplitSparseBuffer variant assumes that the C code may not
tightly pack the data with single null bytes and thus will not
return any empty strings (unless the input buffer is empty
or only contains nulls).
Most of the code in the go-ceph codebase is doing the latter but
probably should have been doing the former. Thus both approaches
are provided.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-23 16:38:39 -04:00