zig

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

commit 737b366279984b5725673ef94b0e144ac5eca98e (tree)
parent feff968ec3b1edb0234549854b8ebbc95276bd18
Author: xdBronch <51252236+xdBronch@users.noreply.github.com>
Date:   Tue, 25 Jul 2023 07:01:49 -0400

add error when passing a non-single-item pointer to allocator.destroy

Diffstat:
Mlib/std/mem/Allocator.zig | 1+
1 file changed, 1 insertion(+), 0 deletions(-)

diff --git a/lib/std/mem/Allocator.zig b/lib/std/mem/Allocator.zig @@ -110,6 +110,7 @@ pub fn create(self: Allocator, comptime T: type) Error!*T { /// have the same address and alignment property. pub fn destroy(self: Allocator, ptr: anytype) void { const info = @typeInfo(@TypeOf(ptr)).Pointer; + if (info.size != .One) @compileError("ptr must be a single item pointer"); const T = info.child; if (@sizeOf(T) == 0) return; const non_const_ptr = @as([*]u8, @ptrCast(@constCast(ptr)));