| ... | ... | @@ -561,11 +561,13 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 561 | 561 | } |
| 562 | 562 | self.total_requested_bytes = new_req_bytes; |
| 563 | 563 | } |
| 564 | | errdefer if (config.enable_memory_limit) { |
| 565 | | self.total_requested_bytes = prev_req_bytes; |
| 566 | | }; |
| 567 | 564 | |
| 568 | | const result_len = self.backing_allocator.rawResize(old_mem, old_align, new_size, len_align, ret_addr) orelse return null; |
| 565 | const result_len = self.backing_allocator.rawResize(old_mem, old_align, new_size, len_align, ret_addr) orelse { |
| 566 | if (config.enable_memory_limit) { |
| 567 | self.total_requested_bytes = prev_req_bytes; |
| 568 | } |
| 569 | return null; |
| 570 | }; |
| 569 | 571 | |
| 570 | 572 | if (config.enable_memory_limit) { |
| 571 | 573 | entry.value_ptr.requested_size = new_size; |
| ... | ... | @@ -623,6 +625,10 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 623 | 625 | }); |
| 624 | 626 | } |
| 625 | 627 | |
| 628 | if (!config.never_unmap) { |
| 629 | self.backing_allocator.rawFree(old_mem, old_align, ret_addr); |
| 630 | } |
| 631 | |
| 626 | 632 | if (config.enable_memory_limit) { |
| 627 | 633 | self.total_requested_bytes -= entry.value_ptr.requested_size; |
| 628 | 634 | } |
| ... | ... | @@ -711,9 +717,6 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 711 | 717 | } |
| 712 | 718 | self.total_requested_bytes = new_req_bytes; |
| 713 | 719 | } |
| 714 | | errdefer if (config.enable_memory_limit) { |
| 715 | | self.total_requested_bytes = prev_req_bytes; |
| 716 | | }; |
| 717 | 720 | |
| 718 | 721 | const new_aligned_size = math.max(new_size, old_align); |
| 719 | 722 | const new_size_class = math.ceilPowerOfTwoAssert(usize, new_aligned_size); |
| ... | ... | @@ -728,6 +731,10 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 728 | 731 | } |
| 729 | 732 | return new_size; |
| 730 | 733 | } |
| 734 | |
| 735 | if (config.enable_memory_limit) { |
| 736 | self.total_requested_bytes = prev_req_bytes; |
| 737 | } |
| 731 | 738 | return null; |
| 732 | 739 | } |
| 733 | 740 | |