zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit bd5dc75068dcfb3dcd6b8197ee5d941cacb15cb9 (tree)
parent 6015192fb62f4dac430a23227df21ab6368e8e07
Author: Meghan Denny <hello@nektro.net>
Date:   Tue, 10 Mar 2026 14:17:40 -0700

std: remove GeneralPurposeAllocator alias

Diffstat:
Mdoc/langref.html.in | 2+-
Mlib/compiler/aro/main.zig | 2+-
Mlib/std/hash/benchmark.zig | 2+-
Mlib/std/heap.zig | 6+-----
Mlib/std/testing.zig | 4++--
Mtest/standalone/child_process/main.zig | 2+-
Mtools/generate_c_size_and_align_checks.zig | 2+-
7 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/doc/langref.html.in b/doc/langref.html.in @@ -6368,7 +6368,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val </p> <p> Zig has a general purpose allocator available to be imported - with {#syntax#}std.heap.GeneralPurposeAllocator{#endsyntax#}. However, it is still recommended to + with {#syntax#}std.heap.DebugAllocator{#endsyntax#}. However, it is still recommended to follow the {#link|Choosing an Allocator#} guide. </p> diff --git a/lib/compiler/aro/main.zig b/lib/compiler/aro/main.zig @@ -13,7 +13,7 @@ const assembly_backend = @import("assembly_backend"); var debug_allocator: std.heap.DebugAllocator(.{ .stack_trace_frames = 0, // A unique value so that when a default-constructed - // GeneralPurposeAllocator is incorrectly passed to testing allocator, or + // DebugAllocator is incorrectly passed to testing allocator, or // vice versa, panic occurs. .canary = @truncate(0xc647026dc6875134), }) = .{}; diff --git a/lib/std/hash/benchmark.zig b/lib/std/hash/benchmark.zig @@ -440,7 +440,7 @@ pub fn main(init: std.process.Init) !void { std.process.exit(1); } - var gpa: std.heap.GeneralPurposeAllocator(.{}) = .init; + var gpa: std.heap.DebugAllocator(.{}) = .init; defer std.testing.expect(gpa.deinit() == .ok) catch @panic("leak"); const allocator = gpa.allocator(); diff --git a/lib/std/heap.zig b/lib/std/heap.zig @@ -19,10 +19,6 @@ pub const BrkAllocator = @import("heap/BrkAllocator.zig"); pub const DebugAllocatorConfig = @import("heap/debug_allocator.zig").Config; pub const DebugAllocator = @import("heap/debug_allocator.zig").DebugAllocator; pub const Check = enum { ok, leak }; -/// Deprecated; to be removed after 0.14.0 is tagged. -pub const GeneralPurposeAllocatorConfig = DebugAllocatorConfig; -/// Deprecated; to be removed after 0.14.0 is tagged. -pub const GeneralPurposeAllocator = DebugAllocator; /// A memory pool that can allocate objects of a single type very quickly. /// Use this when you need to allocate a lot of objects of the same type, @@ -1006,7 +1002,7 @@ const page_size_max_default: ?usize = switch (builtin.os.tag) { test { _ = @import("heap/memory_pool.zig"); _ = ArenaAllocator; - _ = GeneralPurposeAllocator; + _ = DebugAllocator(.{}); _ = FixedBufferAllocator; if (builtin.single_threaded) { if (builtin.cpu.arch.isWasm() or (builtin.os.tag == .linux and !builtin.link_libc)) { diff --git a/lib/std/testing.zig b/lib/std/testing.zig @@ -19,11 +19,11 @@ var base_allocator_instance = std.heap.FixedBufferAllocator.init(""); /// This should only be used in temporary test programs. pub const allocator = allocator_instance.allocator(); -pub var allocator_instance: std.heap.GeneralPurposeAllocator(.{ +pub var allocator_instance: std.heap.DebugAllocator(.{ .stack_trace_frames = if (std.debug.sys_can_stack_trace) 10 else 0, .resize_stack_traces = true, // A unique value so that when a default-constructed - // GeneralPurposeAllocator is incorrectly passed to testing allocator, or + // DebugAllocator is incorrectly passed to testing allocator, or // vice versa, panic occurs. .canary = @truncate(0x2731e675c3a701ba), }) = b: { diff --git a/test/standalone/child_process/main.zig b/test/standalone/child_process/main.zig @@ -3,7 +3,7 @@ const Io = std.Io; pub fn main(init: std.process.Init.Minimal) !void { // make sure safety checks are enabled even in release modes - var gpa_state: std.heap.GeneralPurposeAllocator(.{ .safety = true }) = .{}; + var gpa_state: std.heap.DebugAllocator(.{ .safety = true }) = .{}; defer if (gpa_state.deinit() != .ok) { @panic("found memory leaks"); }; diff --git a/tools/generate_c_size_and_align_checks.zig b/tools/generate_c_size_and_align_checks.zig @@ -26,7 +26,7 @@ fn cName(ty: std.Target.CType) []const u8 { }; } -var general_purpose_allocator: std.heap.GeneralPurposeAllocator(.{}) = .init; +var general_purpose_allocator: std.heap.DebugAllocator(.{}) = .init; pub fn main(init: std.process.Init) !void { const args = try init.minimal.args.toSlice(init.arena.allocator());