Skip to content

Commit

Permalink
use gpa
Browse files Browse the repository at this point in the history
  • Loading branch information
jiacai2050 committed Jan 4, 2025
1 parent e2f845a commit 63706e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/01-05.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ const fs = std.fs;
const print = std.debug.print;

pub fn main() !void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const allocator = arena.allocator();
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer if (gpa.deinit() != .ok) @panic("leak");
const allocator = gpa.allocator();

// In order to walk the directry, `iterate` must be set to true.
var dir = try fs.cwd().openDir(".", .{ .iterate = true });
var dir = try fs.cwd().openDir("zig-out", .{ .iterate = true });
defer dir.close();

var walker = try dir.walk(allocator);
Expand Down
6 changes: 3 additions & 3 deletions src/08-02.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const Child = std.process.Child;
const ArrayList = std.ArrayList;

pub fn main() !void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const allocator = arena.allocator();
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer if (gpa.deinit() != .ok) @panic("leak");
const allocator = gpa.allocator();

const argv = [_][]const u8{
"echo",
Expand Down

0 comments on commit 63706e0

Please sign in to comment.