Skip to content

Commit

Permalink
Allow allocation of any 0 sized type (not just void)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hejsil committed Jul 4, 2018
1 parent 291afcf commit 4f32b86
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion std/mem.zig
Expand Up @@ -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;
Expand Down

0 comments on commit 4f32b86

Please sign in to comment.