Functions

fn readILEB128(comptime T: type, reader: anytype) !T

Read a single signed LEB128 value from the given reader as type T, or error.Ove…

Read a single signed LEB128 value from the given reader as type T, or error.Overflow if the value cannot fit.

fn readULEB128(comptime T: type, reader: anytype) !T

Read a single unsigned LEB128 value from the given reader as type T, or error.O…

Read a single unsigned LEB128 value from the given reader as type T, or error.Overflow if the value cannot fit.

fn writeILEB128(writer: anytype, int_value: anytype) !void

Write a single signed integer as signed LEB128 to the given writer.

fn writeULEB128(writer: anytype, uint_value: anytype) !void

Write a single unsigned integer as unsigned LEB128 to the given writer.

fn writeUnsignedFixed(comptime l: usize, ptr: *[l]u8, int: field_call) void

This is an “advanced” function. It allows one to use a fixed amount of memory to…

This is an “advanced” function. It allows one to use a fixed amount of memory to store a ULEB128. This defeats the entire purpose of using this data encoding; it will no longer use fewer bytes to store smaller numbers. The advantage of using a fixed width is that it makes fields have a predictable size and so depending on the use case this tradeoff can be worthwhile. An example use case of this is in emitting DWARF info where one wants to make a ULEB128 field “relocatable”, meaning that it becomes possible to later go back and patch the number to be a different value without shifting all the following code.