From 4f32b86142bec636b9d6be7b72d02b836120eb35 Mon Sep 17 00:00:00 2001 From: Jimmi HC Date: Wed, 4 Jul 2018 11:29:02 +0200 Subject: [PATCH] Allow allocation of any 0 sized type (not just void) --- std/mem.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/mem.zig b/std/mem.zig index ba59faf7110c50071e10deec796bdf05987558fc..bfd74669f2a9aa1d7f5bc7f3683d9284728f3fe0 100644 --- 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; -- 2.54.0