std: remove GeneralPurposeAllocator alias

This commit is contained in:
Meghan Denny
2026-03-10 14:17:40 -07:00
committed by Andrew Kelley
parent 6015192fb6
commit bd5dc75068
7 changed files with 8 additions and 12 deletions
+1 -1
View File
@@ -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>
+1 -1
View File
@@ -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),
}) = .{};
+1 -1
View File
@@ -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();
+1 -5
View File
@@ -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)) {
+2 -2
View File
@@ -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: {
+1 -1
View File
@@ -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");
};
+1 -1
View File
@@ -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());