File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1013,13 +1013,15 @@ bool gc_never_free(void *ptr) {
10131013 // Pointers are stored in a linked list where each block is BYTES_PER_BLOCK long and the first
10141014 // pointer is the next block of pointers.
10151015 void * * current_reference_block = MP_STATE_MEM (permanent_pointers );
1016+ void * * last_reference_block = NULL ;
10161017 while (current_reference_block != NULL ) {
10171018 for (size_t i = 1 ; i < BYTES_PER_BLOCK / sizeof (void * ); i ++ ) {
10181019 if (current_reference_block [i ] == NULL ) {
10191020 current_reference_block [i ] = ptr ;
10201021 return true;
10211022 }
10221023 }
1024+ last_reference_block = current_reference_block ; // keep a record of last "proper" reference block
10231025 current_reference_block = current_reference_block [0 ];
10241026 }
10251027 void * * next_block = gc_alloc (BYTES_PER_BLOCK , false, true);
@@ -1029,7 +1031,7 @@ bool gc_never_free(void *ptr) {
10291031 if (MP_STATE_MEM (permanent_pointers ) == NULL ) {
10301032 MP_STATE_MEM (permanent_pointers ) = next_block ;
10311033 } else {
1032- current_reference_block [0 ] = next_block ;
1034+ last_reference_block [0 ] = next_block ;
10331035 }
10341036 next_block [1 ] = ptr ;
10351037 return true;
You can’t perform that action at this time.
0 commit comments