From 0b34439c1f380a1a9e26d219550a1cfd31fa698e Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 23 Jan 2017 00:11:21 -0500 Subject: [PATCH] mem.free no longer requires explicit type argument --- std/debug.zig | 2 +- std/elf.zig | 4 ++-- std/hash_map.zig | 4 ++-- std/list.zig | 2 +- std/mem.zig | 3 +-- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/std/debug.zig b/std/debug.zig index 6ea77c03c5..4051ff123a 100644 --- a/std/debug.zig +++ b/std/debug.zig @@ -196,7 +196,7 @@ fn getString(st: &ElfStackTrace, offset: u64) -> %[]u8 { fn readAllocBytes(in_stream: &io.InStream, size: usize) -> %[]u8 { const buf = %return global_allocator.alloc(u8, size); - %defer global_allocator.free(u8, buf); + %defer global_allocator.free(buf); %return in_stream.read(buf); return buf; } diff --git a/std/elf.zig b/std/elf.zig index a48987f559..704f1e1870 100644 --- a/std/elf.zig +++ b/std/elf.zig @@ -180,7 +180,7 @@ pub const Elf = struct { %return elf.in_stream.seekTo(elf.section_header_offset); elf.section_headers = %return elf.allocator.alloc(SectionHeader, sh_entry_count); - %defer elf.allocator.free(SectionHeader, elf.section_headers); + %defer elf.allocator.free(elf.section_headers); if (elf.is_64) { if (sh_entry_size != 64) return error.InvalidFormat; @@ -231,7 +231,7 @@ pub const Elf = struct { } pub fn close(elf: &Elf) { - elf.allocator.free(SectionHeader, elf.section_headers); + elf.allocator.free(elf.section_headers); if (elf.auto_close_stream) elf.in_stream.close(); diff --git a/std/hash_map.zig b/std/hash_map.zig index 27c80b787e..4cdf098d5a 100644 --- a/std/hash_map.zig +++ b/std/hash_map.zig @@ -63,7 +63,7 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn(key: K)->u3 } pub fn deinit(hm: &Self) { - hm.allocator.free(Entry, hm.entries); + hm.allocator.free(hm.entries); } pub fn clear(hm: &Self) { @@ -91,7 +91,7 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn(key: K)->u3 hm.internalPut(old_entry.key, old_entry.value); } } - hm.allocator.free(Entry, old_entries); + hm.allocator.free(old_entries); } hm.internalPut(key, value); diff --git a/std/list.zig b/std/list.zig index b0b4ee2df0..c79505ef50 100644 --- a/std/list.zig +++ b/std/list.zig @@ -20,7 +20,7 @@ pub fn List(comptime T: type) -> type{ } pub fn deinit(l: &Self) { - l.allocator.free(T, l.items); + l.allocator.free(l.items); } pub fn toSlice(l: &const Self) -> []const T { diff --git a/std/mem.zig b/std/mem.zig index 9059f9580d..8aa18348b2 100644 --- a/std/mem.zig +++ b/std/mem.zig @@ -35,8 +35,7 @@ pub const Allocator = struct { ([]T)(%return self.reallocFn(self, ([]u8)(old_mem), byte_count)) } - // TODO mem: []var and get rid of 2nd param - fn free(self: &Allocator, comptime T: type, mem: []T) { + fn free(self: &Allocator, mem: var) { self.freeFn(self, ([]u8)(mem)); } };