Skip to content

Commit daebf9d

Browse files
committed
Use umf_ba_linear_free in the proxy library
Signed-off-by: Lukasz Dorau <[email protected]>
1 parent 0f4ddc5 commit daebf9d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/proxy_lib/proxy_lib.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ static inline void *ba_generic_realloc(umf_ba_linear_pool_t *pool, void *ptr,
127127

128128
memcpy(new_ptr, ptr, new_size);
129129

130+
// we can free the old ptr now
131+
umf_ba_linear_free(pool, ptr);
132+
130133
return new_ptr;
131134
}
132135

@@ -136,7 +139,7 @@ static inline void *ba_generic_realloc(umf_ba_linear_pool_t *pool, void *ptr,
136139

137140
static void ba_leak_create(void) { Base_alloc_leak = umf_ba_linear_create(0); }
138141

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
140143

141144
static inline void *ba_leak_malloc(size_t size) {
142145
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) {
160163
return (void *)ALIGN_UP((uintptr_t)ptr, alignment);
161164
}
162165

166+
static inline int ba_leak_free(void *ptr) {
167+
return umf_ba_linear_free(Base_alloc_leak, ptr);
168+
}
169+
163170
static inline size_t ba_leak_pool_contains_pointer(void *ptr) {
164171
return umf_ba_linear_pool_contains_pointer(Base_alloc_leak, ptr);
165172
}
@@ -221,8 +228,7 @@ void free(void *ptr) {
221228
return;
222229
}
223230

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) {
226232
return;
227233
}
228234

0 commit comments

Comments
 (0)