authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-23 00:11:21-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-23 00:11:21-05:00
log0b34439c1f380a1a9e26d219550a1cfd31fa698e
treee1fac39142d7e4963a542826f8fee0d4661c2d7b
parente5b17580107ad0783b7f07de100aeb9ccf175603

mem.free no longer requires explicit type argument


5 files changed, 7 insertions(+), 8 deletions(-)

std/debug.zig+1-1
......@@ -196,7 +196,7 @@ fn getString(st: &ElfStackTrace, offset: u64) -> %[]u8 {
196196
197197fn readAllocBytes(in_stream: &io.InStream, size: usize) -> %[]u8 {
198198 const buf = %return global_allocator.alloc(u8, size);
199 %defer global_allocator.free(u8, buf);
199 %defer global_allocator.free(buf);
200200 %return in_stream.read(buf);
201201 return buf;
202202}
std/elf.zig+2-2
......@@ -180,7 +180,7 @@ pub const Elf = struct {
180180 %return elf.in_stream.seekTo(elf.section_header_offset);
181181
182182 elf.section_headers = %return elf.allocator.alloc(SectionHeader, sh_entry_count);
183 %defer elf.allocator.free(SectionHeader, elf.section_headers);
183 %defer elf.allocator.free(elf.section_headers);
184184
185185 if (elf.is_64) {
186186 if (sh_entry_size != 64) return error.InvalidFormat;
......@@ -231,7 +231,7 @@ pub const Elf = struct {
231231 }
232232
233233 pub fn close(elf: &Elf) {
234 elf.allocator.free(SectionHeader, elf.section_headers);
234 elf.allocator.free(elf.section_headers);
235235
236236 if (elf.auto_close_stream)
237237 elf.in_stream.close();
std/hash_map.zig+2-2
......@@ -63,7 +63,7 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn(key: K)->u3
6363 }
6464
6565 pub fn deinit(hm: &Self) {
66 hm.allocator.free(Entry, hm.entries);
66 hm.allocator.free(hm.entries);
6767 }
6868
6969 pub fn clear(hm: &Self) {
......@@ -91,7 +91,7 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn(key: K)->u3
9191 hm.internalPut(old_entry.key, old_entry.value);
9292 }
9393 }
94 hm.allocator.free(Entry, old_entries);
94 hm.allocator.free(old_entries);
9595 }
9696
9797 hm.internalPut(key, value);
std/list.zig+1-1
......@@ -20,7 +20,7 @@ pub fn List(comptime T: type) -> type{
2020 }
2121
2222 pub fn deinit(l: &Self) {
23 l.allocator.free(T, l.items);
23 l.allocator.free(l.items);
2424 }
2525
2626 pub fn toSlice(l: &const Self) -> []const T {
std/mem.zig+1-2
......@@ -35,8 +35,7 @@ pub const Allocator = struct {
3535 ([]T)(%return self.reallocFn(self, ([]u8)(old_mem), byte_count))
3636 }
3737
38 // TODO mem: []var and get rid of 2nd param
39 fn free(self: &Allocator, comptime T: type, mem: []T) {
38 fn free(self: &Allocator, mem: var) {
4039 self.freeFn(self, ([]u8)(mem));
4140 }
4241};