DoxigAlpha

writeBlob

Function parameters

Parameters

#
self:*BcWriter
blob:[]const u8

Type definitions in this namespace

Types

#

Functions in this namespace

Functions

#

Error sets in this namespace

Error Sets

#

Source

Implementation

#
pub fn writeBlob(self: *BcWriter, blob: []const u8) Error!void {
    const blob_word_size = std.mem.alignForward(usize, blob.len, 4);
    try self.buffer.ensureUnusedCapacity(blob_word_size + 1);
    self.alignTo32() catch unreachable;

    const slice = self.buffer.addManyAsSliceAssumeCapacity(blob_word_size / 4);
    const slice_bytes = std.mem.sliceAsBytes(slice);
    @memcpy(slice_bytes[0..blob.len], blob);
    @memset(slice_bytes[blob.len..], 0);
}