johan0A/gc.zig
a Zig garbage collector interface for the bdwgc garbage collector.
9e224cb87759c1ca420a5cd5c6082d29b9ed58cb
The bdwgc Boehm GC garbage coollector packaged for zig.
const gc = @import("gc");
pub fn main() !void {
const allocator = gc.bdwgc.allocator();
var list: std.ArrayListUnmanaged(u8) = .empty;
try list.appendSlice(allocator, "Hello");
try list.appendSlice(allocator, " World");
std.debug.print("{s}\n", .{list.items});
// the program will exit without memory leaks :D
}
gc
to the depency list in build.zig.zon
:zig fetch --save git+https://github.com/johan0A/gc.zig#v0.1.0
build.zig
:const gc_dep = b.dependency("gc", .{
.target = target,
.optimize = optimize,
});
root_module.addImport("gc", gc_dep.module("gc"));