| author | |
| committer | |
| log | 0b34439c1f380a1a9e26d219550a1cfd31fa698e |
| tree | e1fac39142d7e4963a542826f8fee0d4661c2d7b |
| parent | e5b17580107ad0783b7f07de100aeb9ccf175603 |
5 files changed, 7 insertions(+), 8 deletions(-)
std/debug.zig+1-1| ... | @@ -196,7 +196,7 @@ fn getString(st: &ElfStackTrace, offset: u64) -> %[]u8 { | ... | @@ -196,7 +196,7 @@ fn getString(st: &ElfStackTrace, offset: u64) -> %[]u8 { |
| 196 | 196 | ||
| 197 | fn readAllocBytes(in_stream: &io.InStream, size: usize) -> %[]u8 { | 197 | fn readAllocBytes(in_stream: &io.InStream, size: usize) -> %[]u8 { |
| 198 | const buf = %return global_allocator.alloc(u8, size); | 198 | const buf = %return global_allocator.alloc(u8, size); |
| 199 | %defer global_allocator.free(u8, buf); | 199 | %defer global_allocator.free(buf); |
| 200 | %return in_stream.read(buf); | 200 | %return in_stream.read(buf); |
| 201 | return buf; | 201 | return buf; |
| 202 | } | 202 | } |
std/elf.zig+2-2| ... | @@ -180,7 +180,7 @@ pub const Elf = struct { | ... | @@ -180,7 +180,7 @@ pub const Elf = struct { |
| 180 | %return elf.in_stream.seekTo(elf.section_header_offset); | 180 | %return elf.in_stream.seekTo(elf.section_header_offset); |
| 181 | 181 | ||
| 182 | elf.section_headers = %return elf.allocator.alloc(SectionHeader, sh_entry_count); | 182 | 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); |
| 184 | 184 | ||
| 185 | if (elf.is_64) { | 185 | if (elf.is_64) { |
| 186 | if (sh_entry_size != 64) return error.InvalidFormat; | 186 | if (sh_entry_size != 64) return error.InvalidFormat; |
| ... | @@ -231,7 +231,7 @@ pub const Elf = struct { | ... | @@ -231,7 +231,7 @@ pub const Elf = struct { |
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | pub fn close(elf: &Elf) { | 233 | pub fn close(elf: &Elf) { |
| 234 | elf.allocator.free(SectionHeader, elf.section_headers); | 234 | elf.allocator.free(elf.section_headers); |
| 235 | 235 | ||
| 236 | if (elf.auto_close_stream) | 236 | if (elf.auto_close_stream) |
| 237 | elf.in_stream.close(); | 237 | 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 | ... | @@ -63,7 +63,7 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn(key: K)->u3 |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | pub fn deinit(hm: &Self) { | 65 | pub fn deinit(hm: &Self) { |
| 66 | hm.allocator.free(Entry, hm.entries); | 66 | hm.allocator.free(hm.entries); |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | pub fn clear(hm: &Self) { | 69 | pub fn clear(hm: &Self) { |
| ... | @@ -91,7 +91,7 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn(key: K)->u3 | ... | @@ -91,7 +91,7 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn(key: K)->u3 |
| 91 | hm.internalPut(old_entry.key, old_entry.value); | 91 | hm.internalPut(old_entry.key, old_entry.value); |
| 92 | } | 92 | } |
| 93 | } | 93 | } |
| 94 | hm.allocator.free(Entry, old_entries); | 94 | hm.allocator.free(old_entries); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | hm.internalPut(key, value); | 97 | hm.internalPut(key, value); |
std/list.zig+1-1| ... | @@ -20,7 +20,7 @@ pub fn List(comptime T: type) -> type{ | ... | @@ -20,7 +20,7 @@ pub fn List(comptime T: type) -> type{ |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | pub fn deinit(l: &Self) { | 22 | pub fn deinit(l: &Self) { |
| 23 | l.allocator.free(T, l.items); | 23 | l.allocator.free(l.items); |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | pub fn toSlice(l: &const Self) -> []const T { | 26 | pub fn toSlice(l: &const Self) -> []const T { |
std/mem.zig+1-2| ... | @@ -35,8 +35,7 @@ pub const Allocator = struct { | ... | @@ -35,8 +35,7 @@ pub const Allocator = struct { |
| 35 | ([]T)(%return self.reallocFn(self, ([]u8)(old_mem), byte_count)) | 35 | ([]T)(%return self.reallocFn(self, ([]u8)(old_mem), byte_count)) |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | // TODO mem: []var and get rid of 2nd param | 38 | fn free(self: &Allocator, mem: var) { |
| 39 | fn free(self: &Allocator, comptime T: type, mem: []T) { | ||
| 40 | self.freeFn(self, ([]u8)(mem)); | 39 | self.freeFn(self, ([]u8)(mem)); |
| 41 | } | 40 | } |
| 42 | }; | 41 | }; |