Skip to content

Instantly share code, notes, and snippets.

@50n1cd347h9
Created December 10, 2024 06:32
Show Gist options
  • Save 50n1cd347h9/ec1152ac10484a248477bcbbcec788f2 to your computer and use it in GitHub Desktop.
Save 50n1cd347h9/ec1152ac10484a248477bcbbcec788f2 to your computer and use it in GitHub Desktop.
const std = @import("std");

pub fn main() !void {
    var gpa = std.heap.GeneralPurposeAllocator(.{}){};
    const a = gpa.allocator();

    const hoge_str = try a.dupe(u8, "hogehoge");
    defer a.free(hoge_str);

    std.debug.print("{s}\n", .{hoge_str});
}

output

$ zig run dupe.zig 
hogehoge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment