Skip to content

Instantly share code, notes, and snippets.

@50n1cd347h9
Created December 10, 2024 06:32
Show Gist options
  • Select an option

  • Save 50n1cd347h9/ec1152ac10484a248477bcbbcec788f2 to your computer and use it in GitHub Desktop.

Select an option

Save 50n1cd347h9/ec1152ac10484a248477bcbbcec788f2 to your computer and use it in GitHub Desktop.

Revisions

  1. 50n1cd347h9 created this gist Dec 10, 2024.
    18 changes: 18 additions & 0 deletions dupe.zig.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    ```zig
    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
    ```txt
    $ zig run dupe.zig
    hogehoge
    ```