mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
"Support" allocating 0 bit types
This commit is contained in:
parent
fb3c5b84ed
commit
bf1d83482b
@ -159,7 +159,7 @@ fn moveBytes(
|
||||
/// Returns a pointer to undefined memory.
|
||||
/// Call `destroy` with the result to free the memory.
|
||||
pub fn create(self: *Allocator, comptime T: type) Error!*T {
|
||||
if (@sizeOf(T) == 0) return &(T{});
|
||||
if (@sizeOf(T) == 0) return @as(*T, undefined);
|
||||
const slice = try self.allocAdvancedWithRetAddr(T, null, 1, .exact, @returnAddress());
|
||||
return &slice[0];
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user