@@ -124,7 +124,7 @@ pub fn TracyAllocator(comptime name: ?[:0]const u8) type {
124
124
}
125
125
126
126
fn allocFn (self : * Self , len : usize , ptr_align : u29 , len_align : u29 , ret_addr : usize ) std.mem.Allocator.Error ! []u8 {
127
- const result = self .parent_allocator .allocFn ( self . parent_allocator , len , ptr_align , len_align , ret_addr );
127
+ const result = self .parent_allocator .rawAlloc ( len , ptr_align , len_align , ret_addr );
128
128
if (result ) | data | {
129
129
if (data .len != 0 ) {
130
130
if (name ) | n | {
@@ -139,22 +139,14 @@ pub fn TracyAllocator(comptime name: ?[:0]const u8) type {
139
139
return result ;
140
140
}
141
141
142
- fn resizeFn (self : * Self , buf : []u8 , buf_align : u29 , new_len : usize , len_align : u29 , ret_addr : usize ) std.mem.Allocator.Error ! usize {
143
- if (self .parent_allocator .resizeFn (self .parent_allocator , buf , buf_align , new_len , len_align , ret_addr )) | resized_len | {
144
- // this condition is to handle free being called on an empty slice that was never even allocated
145
- // example case: `std.process.getSelfExeSharedLibPaths` can return `&[_][:0]u8{}`
146
- if (buf .len != 0 ) {
147
- if (name ) | n | {
148
- freeNamed (buf .ptr , n );
149
- } else {
150
- free (buf .ptr );
151
- }
152
- }
153
-
142
+ fn resizeFn (self : * Self , buf : []u8 , buf_align : u29 , new_len : usize , len_align : u29 , ret_addr : usize ) ? usize {
143
+ if (self .parent_allocator .rawResize (buf , buf_align , new_len , len_align , ret_addr )) | resized_len | {
154
144
if (name ) | n | {
145
+ freeNamed (buf .ptr , n );
155
146
allocNamed (buf .ptr , resized_len , n );
156
147
} else {
157
148
alloc (buf .ptr , resized_len );
149
+ free (buf .ptr );
158
150
}
159
151
160
152
return resized_len ;
@@ -167,10 +159,14 @@ pub fn TracyAllocator(comptime name: ?[:0]const u8) type {
167
159
168
160
fn freeFn (self : * Self , buf : []u8 , buf_align : u29 , ret_addr : usize ) void {
169
161
self .parent_allocator .rawFree (buf , buf_align , ret_addr );
170
- if (name ) | n | {
171
- freeNamed (buf .ptr , n );
172
- } else {
173
- free (buf .ptr );
162
+ // this condition is to handle free being called on an empty slice that was never even allocated
163
+ // example case: `std.process.getSelfExeSharedLibPaths` can return `&[_][:0]u8{}`
164
+ if (buf .len != 0 ) {
165
+ if (name ) | n | {
166
+ freeNamed (buf .ptr , n );
167
+ } else {
168
+ free (buf .ptr );
169
+ }
174
170
}
175
171
}
176
172
};
0 commit comments