Skip to documentation
SLOP

tiny.tldr.LinkedImage

Reference tiny.tldr LinkedImage

Defined in object.

API (11)

Actions

Public operations.

Types and contracts

Public types and contracts.

Fields and members

Public fields and members.

No direct callersNo direct callsobjectLinkedImage
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/tldr/src/object.zig:8

zig
pub const LinkedImage = struct {    bytes: []u8,    storage: Storage = .heap,    manifest: incremental.Manifest,    pub const Storage = union(enum) {        heap,        mapped_file: []align(std.heap.page_size_min) u8,        pub const Allocation = struct {            bytes: []u8,            storage: Storage,            pub fn deinit(self: *Allocation, allocator: std.mem.Allocator) void {                switch (self.storage) {                    .heap => allocator.free(self.bytes),                    .mapped_file => |mapping| sys.memory.unmap(mapping),                }                self.* = undefined;            }            pub fn needsZeroFill(self: Allocation) bool {                return switch (self.storage) {                    .heap => true,                    .mapped_file => false,                };            }        };        pub fn allocate(            allocator: std.mem.Allocator,            len: usize,            options: model.LinkOptions,        ) model.Error!Allocation {            if (options.mapped_output_file) |file| {                if (len >= options.mapped_output_min_size) {                    const file_len = std.math.cast(u64, len) orelse return error.OutputFileError;                    file.setLength(sys.fs.debugIo(), 0) catch return error.OutputFileError;                    file.setLength(sys.fs.debugIo(), file_len) catch return error.OutputFileError;                    const mapping = sys.memory.mapSharedFile(file.handle, len, .{ .read = true, .write = true }, 0) catch |err| switch (err) {                        error.UnsupportedPlatform => return heapAllocation(allocator, len),                        else => return error.OutputFileError,                    };                    return .{                        .bytes = mapping[0..len],                        .storage = .{ .mapped_file = mapping },                    };                }            }            return heapAllocation(allocator, len);        }        fn heapAllocation(allocator: std.mem.Allocator, len: usize) model.Error!Allocation {            return .{                .bytes = try allocator.alloc(u8, len),                .storage = .heap,            };        }    };    pub fn deinit(self: *LinkedImage, allocator: std.mem.Allocator) void {        switch (self.storage) {            .heap => allocator.free(self.bytes),            .mapped_file => |mapping| sys.memory.unmap(mapping),        }        self.manifest.deinit(allocator);        self.* = undefined;    }    pub fn isMaterialized(self: LinkedImage) bool {        return switch (self.storage) {            .heap => false,            .mapped_file => true,        };    }    pub fn prepareIncrementalState(        self: *LinkedImage,        allocator: std.mem.Allocator,    ) std.mem.Allocator.Error!incremental.PreparedState {        return try incremental.PreparedState.fromOwnedManifest(allocator, self.manifest.take());    }};

Source: lib/tldr/src/root.zig:72

zig
pub const LinkedImage = object.LinkedImage;
Called byCallsNo direct callersprivate sourcelib.tldr.src.object.LinkedImage.StorageheapAllocationLinkedImage.Storageallocate
Static calls · unresolved targets: 0 · external targets: 3.
Called byCallsNo direct callstest sourcelib.tldr.src.objecttest: linked image moves manifest int...LinkedImagedeinit
Static calls · unresolved targets: 0 · external targets: 3.
Called byCallsNo direct callstest sourcelib.tldr.src.objecttest: linked image moves manifest int...LinkedImageprepareIncrementalState
Static calls · unresolved targets: 0 · external targets: 2.

Audit

Definitions9
Public names18
Members7
Version26.7.0
Revisiondaab053ee433