mirror of https://github.com/thesofproject/sof.git
test: alloc: fix system heap alloc tests
Fixes system heap alloc tests, which crashed due to wrong handling of memory freeing. Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
This commit is contained in:
parent
5b80e81c78
commit
2649ec78aa
|
@ -256,6 +256,16 @@ static void *alloc(struct test_case *tc)
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void alloc_free(void **mem, struct test_case *tc)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (tc->alloc_zone != RZONE_SYS) {
|
||||||
|
for (i = 0; i < tc->alloc_num; ++i)
|
||||||
|
rfree(mem[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void test_lib_alloc_bulk_free(struct test_case *tc)
|
static void test_lib_alloc_bulk_free(struct test_case *tc)
|
||||||
{
|
{
|
||||||
void **all_mem = malloc(sizeof(void *) * tc->alloc_num);
|
void **all_mem = malloc(sizeof(void *) * tc->alloc_num);
|
||||||
|
@ -268,10 +278,9 @@ static void test_lib_alloc_bulk_free(struct test_case *tc)
|
||||||
all_mem[i] = mem;
|
all_mem[i] = mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < tc->alloc_num; ++i)
|
alloc_free(all_mem, tc);
|
||||||
rfree(all_mem[i]);
|
|
||||||
|
|
||||||
rfree(all_mem);
|
free(all_mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_lib_alloc_immediate_free(struct test_case *tc)
|
static void test_lib_alloc_immediate_free(struct test_case *tc)
|
||||||
|
@ -303,10 +312,9 @@ static void test_lib_alloc_zero(struct test_case *tc)
|
||||||
assert_int_equal(mem[j], 0);
|
assert_int_equal(mem[j], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < tc->alloc_num; ++i)
|
alloc_free(all_mem, tc);
|
||||||
rfree(all_mem[i]);
|
|
||||||
|
|
||||||
rfree(all_mem);
|
free(all_mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_lib_alloc(void **state)
|
static void test_lib_alloc(void **state)
|
||||||
|
|
Loading…
Reference in New Issue