authorgravatar for jhc@dismail.deJimmi Holst Christensen <jhc@dismail.de> 2018-07-04 11:29:02+02:00
committergravatar for jhc@dismail.deJimmi Holst Christensen <jhc@dismail.de> 2018-07-04 11:29:02+02:00
log4f32b86142bec636b9d6be7b72d02b836120eb35
tree2cb368ca00434565e42839c35a946e27e2bf3a8d
parent291afcf75ab458e54a8ccd78dfd1531debfd2e40

Allow allocation of any 0 sized type (not just void)


1 files changed, 1 insertions(+), 1 deletions(-)

std/mem.zig+1-1
...@@ -34,7 +34,7 @@ pub const Allocator = struct {...@@ -34,7 +34,7 @@ pub const Allocator = struct {
34 /// Call `destroy` with the result34 /// Call `destroy` with the result
35 pub fn create(self: *Allocator, init: var) Error!*@typeOf(init) {35 pub fn create(self: *Allocator, init: var) Error!*@typeOf(init) {
36 const T = @typeOf(init);36 const T = @typeOf(init);
37 if (@sizeOf(T) == 0) return &{};37 if (@sizeOf(T) == 0) return &T{};
38 const slice = try self.alloc(T, 1);38 const slice = try self.alloc(T, 1);
39 const ptr = &slice[0];39 const ptr = &slice[0];
40 ptr.* = init;40 ptr.* = init;