zig

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

commit 4f32b86142bec636b9d6be7b72d02b836120eb35 (tree)
parent 291afcf75ab458e54a8ccd78dfd1531debfd2e40
Author: Jimmi HC <jhc@liab.dk>
Date:   Wed,  4 Jul 2018 11:29:02 +0200

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

Diffstat:
Mstd/mem.zig | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/std/mem.zig b/std/mem.zig @@ -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;