mirror of
https://github.com/ziglang/zig.git
synced 2024-11-26 23:22:44 +00:00
Allow allocation of any 0 sized type (not just void)
This commit is contained in:
parent
291afcf75a
commit
4f32b86142
@ -34,7 +34,7 @@ pub const Allocator = struct {
|
||||
/// Call `destroy` with the result
|
||||
pub fn create(self: *Allocator, init: var) Error!*@typeOf(init) {
|
||||
const T = @typeOf(init);
|
||||
if (@sizeOf(T) == 0) return &{};
|
||||
if (@sizeOf(T) == 0) return &T{};
|
||||
const slice = try self.alloc(T, 1);
|
||||
const ptr = &slice[0];
|
||||
ptr.* = init;
|
||||
|
Loading…
Reference in New Issue
Block a user