Function allocRemainingAlignedSentinel [src]
Prototype
pub fn allocRemainingAlignedSentinel( r: *Reader, gpa: Allocator, limit: Limit, comptime alignment: std.mem.Alignment, comptime sentinel: ?u8, ) LimitedAllocError!(if (sentinel) |s| [:s]align(alignment.toByteUnits()) u8 else []align(alignment.toByteUnits()) u8) Parameters
r: *Readergpa: Allocatorlimit: Limitalignment: std.mem.Alignmentsentinel: ?u8 Possible Errors
See the Reader implementation for detailed diagnostics.
Source
pub fn allocRemainingAlignedSentinel(
r: *Reader,
gpa: Allocator,
limit: Limit,
comptime alignment: std.mem.Alignment,
comptime sentinel: ?u8,
) LimitedAllocError!(if (sentinel) |s| [:s]align(alignment.toByteUnits()) u8 else []align(alignment.toByteUnits()) u8) {
var buffer: std.array_list.Aligned(u8, alignment) = .empty;
defer buffer.deinit(gpa);
try appendRemainingAligned(r, gpa, alignment, &buffer, limit);
if (sentinel) |s| {
return buffer.toOwnedSliceSentinel(gpa, s);
} else {
return buffer.toOwnedSlice(gpa);
}
}