Anonymous
11/8/2025, 6:19:11 PM
No.107144428
>>107143185
>>107144261
Your AI generated code is embarrassing and fucking retarded. You simply can't implement a smart pointer in zig, there's no concept of a type having any kid of automatic delete behavior when a value goes out of scope. The closest thing you can get is using a scoped arena const std = @import("std");
pub fn main() !void {
var gpa_state: std.heap.DebugAllocator(.{}) = .init;
defer std.debug.assert(gpa_state.deinit() == .ok);
const gpa = gpa_state.allocator();
{ // "smart pointer" scope
var arena_state: std.heap.ArenaAllocator = .init(gpa);
defer arena_state.deinit();
const arena = arena_state.allocator();
// "smart pointers"
const sp1 = try arena.alloc(u8, 100);
_ = sp1;
const sp2 = try arena.alloc(u8, 100);
_ = sp2;
}
// no leaks!
}
>>107144261
Your AI generated code is embarrassing and fucking retarded. You simply can't implement a smart pointer in zig, there's no concept of a type having any kid of automatic delete behavior when a value goes out of scope. The closest thing you can get is using a scoped arena const std = @import("std");
pub fn main() !void {
var gpa_state: std.heap.DebugAllocator(.{}) = .init;
defer std.debug.assert(gpa_state.deinit() == .ok);
const gpa = gpa_state.allocator();
{ // "smart pointer" scope
var arena_state: std.heap.ArenaAllocator = .init(gpa);
defer arena_state.deinit();
const arena = arena_state.allocator();
// "smart pointers"
const sp1 = try arena.alloc(u8, 100);
_ = sp1;
const sp2 = try arena.alloc(u8, 100);
_ = sp2;
}
// no leaks!
}