constructing header

This commit is contained in:
2022-03-18 18:22:35 +01:00
committed by Motiejus Jakštys
parent bb3577f7b3
commit f4012c8694
2 changed files with 47 additions and 38 deletions

View File

@@ -38,6 +38,8 @@ pub const ShellWriter = struct {
};
pub const ShellSections = struct {
// len is the number of shells in this section.
len: u8,
// index points the i'th shell to it's offset in blob. The last
// byte of the i'th shell is index[i+1].
index: BoundedArray(u16, max_shells),
@@ -55,6 +57,7 @@ pub const ShellWriter = struct {
shells: BoundedArray([]const u8, max_shells),
) error{ Overflow, OutOfMemory }!ShellSections {
var self = ShellSections{
.len = @intCast(u8, shells.len),
.index = try BoundedArray(u16, max_shells).init(shells.len),
.blob = try BoundedArray(u8, (max_shells + 1) * max_shell_len).init(0),
.shell2idx = StringHashMap(u8).init(allocator),