Commit 0b34439c1f

Andrew Kelley <superjoe30@gmail.com>
2017-01-23 06:11:21
mem.free no longer requires explicit type argument
1 parent e5b1758
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;
 }
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();
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);
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 {
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));
     }
 };