| author | |
| committer | |
| log | 9377f32c089a925d7e6f1c64c1ce7777d108213c |
| tree | b8f42ee42e8a0825b74be70499a2569184c10c52 |
| parent | 80bbf234e0d31266c72bb6e93db2d2199ac5920d |
| signature |
8 files changed, 90 insertions(+), 66 deletions(-)
lib/std/heap.zig+24-10| ... | ... | @@ -154,8 +154,11 @@ const CAllocator = struct { |
| 154 | 154 | /// `malloc`/`free`, see `raw_c_allocator`. |
| 155 | 155 | pub const c_allocator = Allocator{ |
| 156 | 156 | .ptr = undefined, |
| 157 | .allocFn = CAllocator.alloc, | |
| 158 | .resizeFn = CAllocator.resize, | |
| 157 | .vtable = &c_allocator_vtable, | |
| 158 | }; | |
| 159 | const c_allocator_vtable = Allocator.VTable{ | |
| 160 | .alloc = CAllocator.alloc, | |
| 161 | .resize = CAllocator.resize, | |
| 159 | 162 | }; |
| 160 | 163 | |
| 161 | 164 | /// Asserts allocations are within `@alignOf(std.c.max_align_t)` and directly calls |
| ... | ... | @@ -165,8 +168,11 @@ pub const c_allocator = Allocator{ |
| 165 | 168 | /// than `c_allocator`. |
| 166 | 169 | pub const raw_c_allocator = Allocator{ |
| 167 | 170 | .ptr = undefined, |
| 168 | .allocFn = rawCAlloc, | |
| 169 | .resizeFn = rawCResize, | |
| 171 | .vtable = &raw_c_allocator_vtable, | |
| 172 | }; | |
| 173 | const raw_c_allocator_vtable = Allocator.VTable{ | |
| 174 | .alloc = rawCAlloc, | |
| 175 | .resize = rawCResize, | |
| 170 | 176 | }; |
| 171 | 177 | |
| 172 | 178 | fn rawCAlloc( |
| ... | ... | @@ -208,16 +214,14 @@ fn rawCResize( |
| 208 | 214 | pub const page_allocator = if (builtin.target.isWasm()) |
| 209 | 215 | Allocator{ |
| 210 | 216 | .ptr = undefined, |
| 211 | .allocFn = WasmPageAllocator.alloc, | |
| 212 | .resizeFn = WasmPageAllocator.resize, | |
| 217 | .vtable = &WasmPageAllocator.vtable, | |
| 213 | 218 | } |
| 214 | 219 | else if (builtin.target.os.tag == .freestanding) |
| 215 | 220 | root.os.heap.page_allocator |
| 216 | 221 | else |
| 217 | 222 | Allocator{ |
| 218 | 223 | .ptr = undefined, |
| 219 | .allocFn = PageAllocator.alloc, | |
| 220 | .resizeFn = PageAllocator.resize, | |
| 224 | .vtable = &PageAllocator.vtable, | |
| 221 | 225 | }; |
| 222 | 226 | |
| 223 | 227 | /// Verifies that the adjusted length will still map to the full length |
| ... | ... | @@ -231,6 +235,11 @@ pub fn alignPageAllocLen(full_len: usize, len: usize, len_align: u29) usize { |
| 231 | 235 | pub var next_mmap_addr_hint: ?[*]align(mem.page_size) u8 = null; |
| 232 | 236 | |
| 233 | 237 | const PageAllocator = struct { |
| 238 | const vtable = Allocator.VTable{ | |
| 239 | .alloc = alloc, | |
| 240 | .resize = resize, | |
| 241 | }; | |
| 242 | ||
| 234 | 243 | fn alloc(_: *c_void, n: usize, alignment: u29, len_align: u29, ra: usize) error{OutOfMemory}![]u8 { |
| 235 | 244 | _ = ra; |
| 236 | 245 | assert(n > 0); |
| ... | ... | @@ -400,6 +409,11 @@ const WasmPageAllocator = struct { |
| 400 | 409 | } |
| 401 | 410 | } |
| 402 | 411 | |
| 412 | const vtable = Allocator.VTable{ | |
| 413 | .alloc = alloc, | |
| 414 | .resize = resize, | |
| 415 | }; | |
| 416 | ||
| 403 | 417 | const PageStatus = enum(u1) { |
| 404 | 418 | used = 0, |
| 405 | 419 | free = 1, |
| ... | ... | @@ -807,7 +821,7 @@ pub fn StackFallbackAllocator(comptime size: usize) type { |
| 807 | 821 | return_address: usize, |
| 808 | 822 | ) error{OutOfMemory}![]u8 { |
| 809 | 823 | return FixedBufferAllocator.alloc(&self.fixed_buffer_allocator, len, ptr_align, len_align, return_address) catch |
| 810 | return self.fallback_allocator.allocFn(self.fallback_allocator.ptr, len, ptr_align, len_align, return_address); | |
| 824 | return self.fallback_allocator.vtable.alloc(self.fallback_allocator.ptr, len, ptr_align, len_align, return_address); | |
| 811 | 825 | } |
| 812 | 826 | |
| 813 | 827 | fn resize( |
| ... | ... | @@ -821,7 +835,7 @@ pub fn StackFallbackAllocator(comptime size: usize) type { |
| 821 | 835 | if (self.fixed_buffer_allocator.ownsPtr(buf.ptr)) { |
| 822 | 836 | return FixedBufferAllocator.resize(&self.fixed_buffer_allocator, buf, buf_align, new_len, len_align, return_address); |
| 823 | 837 | } else { |
| 824 | return self.fallback_allocator.resizeFn(self.fallback_allocator.ptr, buf, buf_align, new_len, len_align, return_address); | |
| 838 | return self.fallback_allocator.vtable.resize(self.fallback_allocator.ptr, buf, buf_align, new_len, len_align, return_address); | |
| 825 | 839 | } |
| 826 | 840 | } |
| 827 | 841 | }; |
lib/std/heap/arena_allocator.zig+1-1| ... | ... | @@ -47,7 +47,7 @@ pub const ArenaAllocator = struct { |
| 47 | 47 | const actual_min_size = minimum_size + (@sizeOf(BufNode) + 16); |
| 48 | 48 | const big_enough_len = prev_len + actual_min_size; |
| 49 | 49 | const len = big_enough_len + big_enough_len / 2; |
| 50 | const buf = try self.child_allocator.allocFn(self.child_allocator.ptr, len, @alignOf(BufNode), 1, @returnAddress()); | |
| 50 | const buf = try self.child_allocator.vtable.alloc(self.child_allocator.ptr, len, @alignOf(BufNode), 1, @returnAddress()); | |
| 51 | 51 | const buf_node = @ptrCast(*BufNode, @alignCast(@alignOf(BufNode), buf.ptr)); |
| 52 | 52 | buf_node.* = BufNode{ |
| 53 | 53 | .data = buf, |
lib/std/heap/general_purpose_allocator.zig+1-1| ... | ... | @@ -388,7 +388,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 388 | 388 | var it = self.large_allocations.iterator(); |
| 389 | 389 | while (it.next()) |large| { |
| 390 | 390 | if (large.value_ptr.freed) { |
| 391 | _ = self.backing_allocator.resizeFn(self.backing_allocator.ptr, large.value_ptr.bytes, large.value_ptr.ptr_align, 0, 0, @returnAddress()) catch unreachable; | |
| 391 | _ = self.backing_allocator.vtable.resize(self.backing_allocator.ptr, large.value_ptr.bytes, large.value_ptr.ptr_align, 0, 0, @returnAddress()) catch unreachable; | |
| 392 | 392 | } |
| 393 | 393 | } |
| 394 | 394 | } |
lib/std/heap/log_to_writer_allocator.zig+2-2| ... | ... | @@ -29,7 +29,7 @@ pub fn LogToWriterAllocator(comptime Writer: type) type { |
| 29 | 29 | ra: usize, |
| 30 | 30 | ) error{OutOfMemory}![]u8 { |
| 31 | 31 | self.writer.print("alloc : {}", .{len}) catch {}; |
| 32 | const result = self.parent_allocator.allocFn(self.parent_allocator.ptr, len, ptr_align, len_align, ra); | |
| 32 | const result = self.parent_allocator.vtable.alloc(self.parent_allocator.ptr, len, ptr_align, len_align, ra); | |
| 33 | 33 | if (result) |_| { |
| 34 | 34 | self.writer.print(" success!\n", .{}) catch {}; |
| 35 | 35 | } else |_| { |
| ... | ... | @@ -53,7 +53,7 @@ pub fn LogToWriterAllocator(comptime Writer: type) type { |
| 53 | 53 | } else { |
| 54 | 54 | self.writer.print("expand: {} to {}", .{ buf.len, new_len }) catch {}; |
| 55 | 55 | } |
| 56 | if (self.parent_allocator.resizeFn(self.parent_allocator.ptr, buf, buf_align, new_len, len_align, ra)) |resized_len| { | |
| 56 | if (self.parent_allocator.vtable.resize(self.parent_allocator.ptr, buf, buf_align, new_len, len_align, ra)) |resized_len| { | |
| 57 | 57 | if (new_len > buf.len) { |
| 58 | 58 | self.writer.print(" success!\n", .{}) catch {}; |
| 59 | 59 | } |
lib/std/heap/logging_allocator.zig+2-2| ... | ... | @@ -53,7 +53,7 @@ pub fn ScopedLoggingAllocator( |
| 53 | 53 | len_align: u29, |
| 54 | 54 | ra: usize, |
| 55 | 55 | ) error{OutOfMemory}![]u8 { |
| 56 | const result = self.parent_allocator.allocFn(self.parent_allocator.ptr, len, ptr_align, len_align, ra); | |
| 56 | const result = self.parent_allocator.vtable.alloc(self.parent_allocator.ptr, len, ptr_align, len_align, ra); | |
| 57 | 57 | if (result) |_| { |
| 58 | 58 | logHelper( |
| 59 | 59 | success_log_level, |
| ... | ... | @@ -78,7 +78,7 @@ pub fn ScopedLoggingAllocator( |
| 78 | 78 | len_align: u29, |
| 79 | 79 | ra: usize, |
| 80 | 80 | ) error{OutOfMemory}!usize { |
| 81 | if (self.parent_allocator.resizeFn(self.parent_allocator.ptr, buf, buf_align, new_len, len_align, ra)) |resized_len| { | |
| 81 | if (self.parent_allocator.vtable.resize(self.parent_allocator.ptr, buf, buf_align, new_len, len_align, ra)) |resized_len| { | |
| 82 | 82 | if (new_len == 0) { |
| 83 | 83 | logHelper(success_log_level, "free - success - len: {}", .{buf.len}); |
| 84 | 84 | } else if (new_len <= buf.len) { |
lib/std/mem.zig+11-7| ... | ... | @@ -70,7 +70,7 @@ pub fn ValidationAllocator(comptime T: type) type { |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | const underlying = self.getUnderlyingAllocatorPtr(); |
| 73 | const result = try underlying.allocFn(underlying.ptr, n, ptr_align, len_align, ret_addr); | |
| 73 | const result = try underlying.vtable.alloc(underlying.ptr, n, ptr_align, len_align, ret_addr); | |
| 74 | 74 | assert(mem.isAligned(@ptrToInt(result.ptr), ptr_align)); |
| 75 | 75 | if (len_align == 0) { |
| 76 | 76 | assert(result.len == n); |
| ... | ... | @@ -95,7 +95,7 @@ pub fn ValidationAllocator(comptime T: type) type { |
| 95 | 95 | assert(new_len >= len_align); |
| 96 | 96 | } |
| 97 | 97 | const underlying = self.getUnderlyingAllocatorPtr(); |
| 98 | const result = try underlying.resizeFn(underlying.ptr, buf, buf_align, new_len, len_align, ret_addr); | |
| 98 | const result = try underlying.vtable.resize(underlying.ptr, buf, buf_align, new_len, len_align, ret_addr); | |
| 99 | 99 | if (len_align == 0) { |
| 100 | 100 | assert(result == new_len); |
| 101 | 101 | } else { |
| ... | ... | @@ -131,10 +131,14 @@ pub fn alignAllocLen(full_len: usize, alloc_len: usize, len_align: u29) usize { |
| 131 | 131 | return adjusted; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | const failAllocator = Allocator{ | |
| 134 | const fail_allocator = Allocator{ | |
| 135 | 135 | .ptr = undefined, |
| 136 | .allocFn = failAllocatorAlloc, | |
| 137 | .resizeFn = Allocator.NoResize(c_void).noResize, | |
| 136 | .vtable = &failAllocator_vtable, | |
| 137 | }; | |
| 138 | ||
| 139 | const failAllocator_vtable = Allocator.VTable{ | |
| 140 | .alloc = failAllocatorAlloc, | |
| 141 | .resize = Allocator.NoResize(c_void).noResize, | |
| 138 | 142 | }; |
| 139 | 143 | |
| 140 | 144 | fn failAllocatorAlloc(_: *c_void, n: usize, alignment: u29, len_align: u29, ra: usize) Allocator.Error![]u8 { |
| ... | ... | @@ -146,8 +150,8 @@ fn failAllocatorAlloc(_: *c_void, n: usize, alignment: u29, len_align: u29, ra: |
| 146 | 150 | } |
| 147 | 151 | |
| 148 | 152 | test "mem.Allocator basics" { |
| 149 | try testing.expectError(error.OutOfMemory, failAllocator.alloc(u8, 1)); | |
| 150 | try testing.expectError(error.OutOfMemory, failAllocator.allocSentinel(u8, 1, 0)); | |
| 153 | try testing.expectError(error.OutOfMemory, fail_allocator.alloc(u8, 1)); | |
| 154 | try testing.expectError(error.OutOfMemory, fail_allocator.allocSentinel(u8, 1, 0)); | |
| 151 | 155 | } |
| 152 | 156 | |
| 153 | 157 | test "Allocator.resize" { |
lib/std/mem/Allocator.zig+47-41| ... | ... | @@ -10,39 +10,42 @@ pub const Error = error{OutOfMemory}; |
| 10 | 10 | |
| 11 | 11 | // The type erased pointer to the allocator implementation |
| 12 | 12 | ptr: *c_void, |
| 13 | ||
| 14 | /// Attempt to allocate at least `len` bytes aligned to `ptr_align`. | |
| 15 | /// | |
| 16 | /// If `len_align` is `0`, then the length returned MUST be exactly `len` bytes, | |
| 17 | /// otherwise, the length must be aligned to `len_align`. | |
| 18 | /// | |
| 19 | /// `len` must be greater than or equal to `len_align` and must be aligned by `len_align`. | |
| 20 | /// | |
| 21 | /// `ret_addr` is optionally provided as the first return address of the allocation call stack. | |
| 22 | /// If the value is `0` it means no return address has been provided. | |
| 23 | allocFn: fn (ptr: *c_void, len: usize, ptr_align: u29, len_align: u29, ret_addr: usize) Error![]u8, | |
| 24 | ||
| 25 | /// Attempt to expand or shrink memory in place. `buf.len` must equal the most recent | |
| 26 | /// length returned by `allocFn` or `resizeFn`. `buf_align` must equal the same value | |
| 27 | /// that was passed as the `ptr_align` parameter to the original `allocFn` call. | |
| 28 | /// | |
| 29 | /// Passing a `new_len` of 0 frees and invalidates the buffer such that it can no | |
| 30 | /// longer be passed to `resizeFn`. | |
| 31 | /// | |
| 32 | /// error.OutOfMemory can only be returned if `new_len` is greater than `buf.len`. | |
| 33 | /// If `buf` cannot be expanded to accomodate `new_len`, then the allocation MUST be | |
| 34 | /// unmodified and error.OutOfMemory MUST be returned. | |
| 35 | /// | |
| 36 | /// If `len_align` is `0`, then the length returned MUST be exactly `len` bytes, | |
| 37 | /// otherwise, the length must be aligned to `len_align`. Note that `len_align` does *not* | |
| 38 | /// provide a way to modify the alignment of a pointer. Rather it provides an API for | |
| 39 | /// accepting more bytes of memory from the allocator than requested. | |
| 40 | /// | |
| 41 | /// `new_len` must be greater than or equal to `len_align` and must be aligned by `len_align`. | |
| 42 | /// | |
| 43 | /// `ret_addr` is optionally provided as the first return address of the allocation call stack. | |
| 44 | /// If the value is `0` it means no return address has been provided. | |
| 45 | resizeFn: fn (ptr: *c_void, buf: []u8, buf_align: u29, new_len: usize, len_align: u29, ret_addr: usize) Error!usize, | |
| 13 | vtable: *const VTable, | |
| 14 | ||
| 15 | pub const VTable = struct { | |
| 16 | /// Attempt to allocate at least `len` bytes aligned to `ptr_align`. | |
| 17 | /// | |
| 18 | /// If `len_align` is `0`, then the length returned MUST be exactly `len` bytes, | |
| 19 | /// otherwise, the length must be aligned to `len_align`. | |
| 20 | /// | |
| 21 | /// `len` must be greater than or equal to `len_align` and must be aligned by `len_align`. | |
| 22 | /// | |
| 23 | /// `ret_addr` is optionally provided as the first return address of the allocation call stack. | |
| 24 | /// If the value is `0` it means no return address has been provided. | |
| 25 | alloc: fn (ptr: *c_void, len: usize, ptr_align: u29, len_align: u29, ret_addr: usize) Error![]u8, | |
| 26 | ||
| 27 | /// Attempt to expand or shrink memory in place. `buf.len` must equal the most recent | |
| 28 | /// length returned by `alloc` or `resize`. `buf_align` must equal the same value | |
| 29 | /// that was passed as the `ptr_align` parameter to the original `alloc` call. | |
| 30 | /// | |
| 31 | /// Passing a `new_len` of 0 frees and invalidates the buffer such that it can no | |
| 32 | /// longer be passed to `resize`. | |
| 33 | /// | |
| 34 | /// error.OutOfMemory can only be returned if `new_len` is greater than `buf.len`. | |
| 35 | /// If `buf` cannot be expanded to accomodate `new_len`, then the allocation MUST be | |
| 36 | /// unmodified and error.OutOfMemory MUST be returned. | |
| 37 | /// | |
| 38 | /// If `len_align` is `0`, then the length returned MUST be exactly `len` bytes, | |
| 39 | /// otherwise, the length must be aligned to `len_align`. Note that `len_align` does *not* | |
| 40 | /// provide a way to modify the alignment of a pointer. Rather it provides an API for | |
| 41 | /// accepting more bytes of memory from the allocator than requested. | |
| 42 | /// | |
| 43 | /// `new_len` must be greater than or equal to `len_align` and must be aligned by `len_align`. | |
| 44 | /// | |
| 45 | /// `ret_addr` is optionally provided as the first return address of the allocation call stack. | |
| 46 | /// If the value is `0` it means no return address has been provided. | |
| 47 | resize: fn (ptr: *c_void, buf: []u8, buf_align: u29, new_len: usize, len_align: u29, ret_addr: usize) Error!usize, | |
| 48 | }; | |
| 46 | 49 | |
| 47 | 50 | pub fn init( |
| 48 | 51 | pointer: anytype, |
| ... | ... | @@ -64,11 +67,14 @@ pub fn init( |
| 64 | 67 | return resizeFn(self, buf, buf_align, new_len, len_align, ret_addr); |
| 65 | 68 | } |
| 66 | 69 | }; |
| 70 | const vtable = VTable{ | |
| 71 | .alloc = gen.alloc, | |
| 72 | .resize = gen.resize, | |
| 73 | }; | |
| 67 | 74 | |
| 68 | 75 | return .{ |
| 69 | 76 | .ptr = pointer, |
| 70 | .allocFn = gen.alloc, | |
| 71 | .resizeFn = gen.resize, | |
| 77 | .vtable = &vtable, | |
| 72 | 78 | }; |
| 73 | 79 | } |
| 74 | 80 | |
| ... | ... | @@ -141,7 +147,7 @@ fn reallocBytes( |
| 141 | 147 | return_address: usize, |
| 142 | 148 | ) Error![]u8 { |
| 143 | 149 | if (old_mem.len == 0) { |
| 144 | const new_mem = try self.allocFn(self.ptr, new_byte_count, new_alignment, len_align, return_address); | |
| 150 | const new_mem = try self.vtable.alloc(self.ptr, new_byte_count, new_alignment, len_align, return_address); | |
| 145 | 151 | // TODO: https://github.com/ziglang/zig/issues/4298 |
| 146 | 152 | @memset(new_mem.ptr, undefined, new_byte_count); |
| 147 | 153 | return new_mem; |
| ... | ... | @@ -152,7 +158,7 @@ fn reallocBytes( |
| 152 | 158 | const shrunk_len = self.shrinkBytes(old_mem, old_alignment, new_byte_count, len_align, return_address); |
| 153 | 159 | return old_mem.ptr[0..shrunk_len]; |
| 154 | 160 | } |
| 155 | if (self.resizeFn(self.ptr, old_mem, old_alignment, new_byte_count, len_align, return_address)) |resized_len| { | |
| 161 | if (self.vtable.resize(self.ptr, old_mem, old_alignment, new_byte_count, len_align, return_address)) |resized_len| { | |
| 156 | 162 | assert(resized_len >= new_byte_count); |
| 157 | 163 | // TODO: https://github.com/ziglang/zig/issues/4298 |
| 158 | 164 | @memset(old_mem.ptr + new_byte_count, undefined, resized_len - new_byte_count); |
| ... | ... | @@ -178,7 +184,7 @@ fn moveBytes( |
| 178 | 184 | ) Error![]u8 { |
| 179 | 185 | assert(old_mem.len > 0); |
| 180 | 186 | assert(new_len > 0); |
| 181 | const new_mem = try self.allocFn(self.ptr, new_len, new_alignment, len_align, return_address); | |
| 187 | const new_mem = try self.vtable.alloc(self.ptr, new_len, new_alignment, len_align, return_address); | |
| 182 | 188 | @memcpy(new_mem.ptr, old_mem.ptr, math.min(new_len, old_mem.len)); |
| 183 | 189 | // TODO https://github.com/ziglang/zig/issues/4298 |
| 184 | 190 | @memset(old_mem.ptr, undefined, old_mem.len); |
| ... | ... | @@ -320,7 +326,7 @@ pub fn allocAdvancedWithRetAddr( |
| 320 | 326 | .exact => 0, |
| 321 | 327 | .at_least => size_of_T, |
| 322 | 328 | }; |
| 323 | const byte_slice = try self.allocFn(self.ptr, byte_count, a, len_align, return_address); | |
| 329 | const byte_slice = try self.vtable.alloc(self.ptr, byte_count, a, len_align, return_address); | |
| 324 | 330 | switch (exact) { |
| 325 | 331 | .exact => assert(byte_slice.len == byte_count), |
| 326 | 332 | .at_least => assert(byte_slice.len >= byte_count), |
| ... | ... | @@ -345,7 +351,7 @@ pub fn resize(self: Allocator, old_mem: anytype, new_n: usize) Error!@TypeOf(old |
| 345 | 351 | } |
| 346 | 352 | const old_byte_slice = mem.sliceAsBytes(old_mem); |
| 347 | 353 | const new_byte_count = math.mul(usize, @sizeOf(T), new_n) catch return Error.OutOfMemory; |
| 348 | const rc = try self.resizeFn(self.ptr, old_byte_slice, Slice.alignment, new_byte_count, 0, @returnAddress()); | |
| 354 | const rc = try self.vtable.resize(self.ptr, old_byte_slice, Slice.alignment, new_byte_count, 0, @returnAddress()); | |
| 349 | 355 | assert(rc == new_byte_count); |
| 350 | 356 | const new_byte_slice = old_byte_slice.ptr[0..new_byte_count]; |
| 351 | 357 | return mem.bytesAsSlice(T, new_byte_slice); |
| ... | ... | @@ -514,5 +520,5 @@ pub fn shrinkBytes( |
| 514 | 520 | return_address: usize, |
| 515 | 521 | ) usize { |
| 516 | 522 | assert(new_len <= buf.len); |
| 517 | return self.resizeFn(self.ptr, buf, buf_align, new_len, len_align, return_address) catch unreachable; | |
| 523 | return self.vtable.resize(self.ptr, buf, buf_align, new_len, len_align, return_address) catch unreachable; | |
| 518 | 524 | } |
lib/std/testing/failing_allocator.zig+2-2| ... | ... | @@ -54,7 +54,7 @@ pub const FailingAllocator = struct { |
| 54 | 54 | if (self.index == self.fail_index) { |
| 55 | 55 | return error.OutOfMemory; |
| 56 | 56 | } |
| 57 | const result = try self.internal_allocator.allocFn(self.internal_allocator.ptr, len, ptr_align, len_align, return_address); | |
| 57 | const result = try self.internal_allocator.vtable.alloc(self.internal_allocator.ptr, len, ptr_align, len_align, return_address); | |
| 58 | 58 | self.allocated_bytes += result.len; |
| 59 | 59 | self.allocations += 1; |
| 60 | 60 | self.index += 1; |
| ... | ... | @@ -69,7 +69,7 @@ pub const FailingAllocator = struct { |
| 69 | 69 | len_align: u29, |
| 70 | 70 | ra: usize, |
| 71 | 71 | ) error{OutOfMemory}!usize { |
| 72 | const r = self.internal_allocator.resizeFn(self.internal_allocator.ptr, old_mem, old_align, new_len, len_align, ra) catch |e| { | |
| 72 | const r = self.internal_allocator.vtable.resize(self.internal_allocator.ptr, old_mem, old_align, new_len, len_align, ra) catch |e| { | |
| 73 | 73 | std.debug.assert(new_len > old_mem.len); |
| 74 | 74 | return e; |
| 75 | 75 | }; |