Zig 0.17.0-dev (Split by item)

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 library itself.

valueAlloc

Calls value and stores the result in dynamically allocated memory instead of taking a writer.

Caller owns returned memory.

Stringify.valueAlloc
pub fn valueAlloc(gpa: Allocator, v: anytype, options: Options) error

File

lib/std/json/Stringify.zig:618

Code

pub fn valueAlloc(gpa: Allocator, v: anytype, options: Options) error{OutOfMemory}![]u8 {
    var aw: Writer.Allocating = .init(gpa);
    defer aw.deinit();
    value(v, options, &aw.writer) catch return error.OutOfMemory;
    return aw.toOwnedSlice();
}