Skip to content

Commit

Permalink
fix memory leak caused by tail of trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
jingkaimori committed Nov 1, 2023
1 parent 285109c commit e357b38
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 5 additions & 0 deletions System/Memory/fast_alloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ safe_malloc (size_t sz) {
void*
enlarge_malloc (size_t sz) {
if (alloc_remains < sz) {
if (alloc_remains > 0)
{
ind (alloc_mem) = alloc_ptr (alloc_remains);
alloc_ptr (alloc_remains)= alloc_mem;
}
alloc_mem= (char*) safe_malloc (BLOCK_SIZE);
#ifdef DEBUG_ON
alloc_mem_top= alloc_mem_top >= alloc_mem + BLOCK_SIZE
Expand Down
8 changes: 1 addition & 7 deletions tests/System/Memory/fast_alloc_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,10 @@ TEST_CASE ("test tm_*_array") {
tm_delete_array (p_wide);
}

TEST_MEMORY_LEAK_ALL
TEST_MEMORY_LEAK_RESET

TEST_CASE ("test tm_*") {
const int bnum=
#ifdef OS_WASM
800;
200;
#else
100000;
#endif
Expand All @@ -103,9 +100,6 @@ TEST_CASE ("test tm_*") {
}
}

TEST_MEMORY_LEAK_ALL
TEST_MEMORY_LEAK_RESET

TEST_CASE ("test tm_*_array with class") {
Complex* volume[NUM];
for (int i= 0; i < NUM; i++) {
Expand Down

0 comments on commit e357b38

Please sign in to comment.