Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Function

allocErrorBundle

Public Function
std.zig.Server.allocErrorBundle
pub fn allocErrorBundle(gpa: Allocator, body: []const u8) error

Params

File

zig/Server.zig:315
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
pub fn allocErrorBundle(gpa: Allocator, body: []const u8) error{ OutOfMemory, EndOfStream }!std.zig.ErrorBundle {
    var r: Reader = .fixed(body);
    const hdr = r.takeStruct(OutMessage.ErrorBundle, .little) catch |err| switch (err) {
        error.EndOfStream => |e| return e,
        error.ReadFailed => unreachable,
    };

    var eb: std.zig.ErrorBundle = .{
        .string_bytes = &.{},
        .extra = &.{},
    };
    errdefer eb.deinit(gpa);

    const extra = try gpa.alloc(u32, hdr.extra_len);
    eb.extra = extra;
    const string_bytes = try gpa.alloc(u8, hdr.string_bytes_len);
    eb.string_bytes = string_bytes;

    r.readSliceEndian(u32, extra, .little) catch |err| switch (err) {
        error.EndOfStream => |e| return e,
        error.ReadFailed => unreachable,
    };
    r.readSliceAll(string_bytes) catch |err| switch (err) {
        error.EndOfStream => |e| return e,
        error.ReadFailed => unreachable,
    };

    return eb;
}