adding simple header validation

This commit is contained in:
2022-02-18 07:42:43 +02:00
committed by Motiejus Jakštys
parent ed1e464305
commit 44107bac51
2 changed files with 65 additions and 9 deletions

View File

@@ -7,8 +7,8 @@ const BoundedArray = std.BoundedArray;
const StringContext = std.hash_map.StringContext;
// MaxShells is the maximum number of "popular" shells.
const MaxShells = 63;
const MaxShellLen = 64;
pub const MaxShells = 63;
pub const MaxShellLen = 64;
// ShellIndex is an index to the shell strings. As shell can be up to 64 bytes
// (1<<6), maximum number of shells is 63 (1<<6-1), the maximum location offset
@@ -22,7 +22,7 @@ const ShellIndex = struct {
};
// ShellReader interprets "Shell Index" and "Shell Blob" sections.
const ShellReader = struct {
pub const ShellReader = struct {
sectionIndex: []const ShellIndex,
sectionBlob: []const u8,
@@ -44,7 +44,7 @@ const ShellReader = struct {
// ShellWriter is a shell popularity contest: collect shells and return the
// popular ones, sorted by score. score := len(shell) * number_of_shells.
const ShellWriter = struct {
pub const ShellWriter = struct {
counts: std.StringHashMap(u32),
allocator: Allocator,
const KV = struct { shell: []const u8, score: u32 };