Skip to content

Commit 08f89a5

Browse files
committed
Move free() before realloc() in the proxy library
Move free() before realloc() in the proxy library, because realloc() calls free(). Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
1 parent 8ac6d3d commit 08f89a5

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/proxy_lib/proxy_lib.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,27 @@ void *calloc(size_t nmemb, size_t size) {
202202
return ba_leak_calloc(nmemb, size);
203203
}
204204

205+
void free(void *ptr) {
206+
if (ptr == NULL) {
207+
return;
208+
}
209+
210+
if (ba_leak_free(ptr) == 0) {
211+
return;
212+
}
213+
214+
if (Proxy_pool) {
215+
if (umfPoolFree(Proxy_pool, ptr) != UMF_RESULT_SUCCESS) {
216+
fprintf(stderr, "error: umfPoolFree() failed\n");
217+
assert(0);
218+
}
219+
return;
220+
}
221+
222+
assert(0);
223+
return;
224+
}
225+
205226
void *realloc(void *ptr, size_t size) {
206227
if (ptr == NULL) {
207228
return malloc(size);
@@ -228,27 +249,6 @@ void *realloc(void *ptr, size_t size) {
228249
return NULL;
229250
}
230251

231-
void free(void *ptr) {
232-
if (ptr == NULL) {
233-
return;
234-
}
235-
236-
if (ba_leak_free(ptr) == 0) {
237-
return;
238-
}
239-
240-
if (Proxy_pool) {
241-
if (umfPoolFree(Proxy_pool, ptr) != UMF_RESULT_SUCCESS) {
242-
fprintf(stderr, "error: umfPoolFree() failed\n");
243-
assert(0);
244-
}
245-
return;
246-
}
247-
248-
assert(0);
249-
return;
250-
}
251-
252252
void *aligned_alloc(size_t alignment, size_t size) {
253253
if (!was_called_from_umfPool && Proxy_pool) {
254254
was_called_from_umfPool = 1;

0 commit comments

Comments
 (0)