@@ -127,6 +127,9 @@ static inline void *ba_generic_realloc(umf_ba_linear_pool_t *pool, void *ptr,
127
127
128
128
memcpy (new_ptr , ptr , new_size );
129
129
130
+ // we can free the old ptr now
131
+ umf_ba_linear_free (pool , ptr );
132
+
130
133
return new_ptr ;
131
134
}
132
135
@@ -136,7 +139,7 @@ static inline void *ba_generic_realloc(umf_ba_linear_pool_t *pool, void *ptr,
136
139
137
140
static void ba_leak_create (void ) { Base_alloc_leak = umf_ba_linear_create (0 ); }
138
141
139
- // it does not implement destroy(), because it will not free memory at all
142
+ // it does not implement destroy(), because we cannot destroy non-freed memory
140
143
141
144
static inline void * ba_leak_malloc (size_t size ) {
142
145
util_init_once (& Base_alloc_leak_initialized , ba_leak_create );
@@ -160,6 +163,10 @@ static inline void *ba_leak_aligned_alloc(size_t alignment, size_t size) {
160
163
return (void * )ALIGN_UP ((uintptr_t )ptr , alignment );
161
164
}
162
165
166
+ static inline int ba_leak_free (void * ptr ) {
167
+ return umf_ba_linear_free (Base_alloc_leak , ptr );
168
+ }
169
+
163
170
static inline size_t ba_leak_pool_contains_pointer (void * ptr ) {
164
171
return umf_ba_linear_pool_contains_pointer (Base_alloc_leak , ptr );
165
172
}
@@ -221,8 +228,7 @@ void free(void *ptr) {
221
228
return ;
222
229
}
223
230
224
- if (ba_leak_pool_contains_pointer (ptr )) {
225
- // allocations from the leak linear base allocator will not be freed at all
231
+ if (ba_leak_free (ptr ) == 0 ) {
226
232
return ;
227
233
}
228
234
0 commit comments