Skip to content

Commit

Permalink
Initialise threads array to NULLs
Browse files Browse the repository at this point in the history
If I'm going to rely on the array containing NULL values, then I should
probably write something into it.
  • Loading branch information
michaelmalonenz committed Jul 1, 2022
1 parent 970ca70 commit 583e8fd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions vmlib/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ void register_thread(VM *vm)
int new_capacity = GROW_CAPACITY(thread_capacity);
threads = GROW_ARRAY(threads, VM*, thread_capacity, new_capacity);
thread_capacity = new_capacity;
for (int i = num_threads; i < new_capacity; i++)
{
threads[i] = NULL;
}
}
threads[num_threads++] = vm;
MUTEX_UNLOCK(gc_lock);
Expand Down

0 comments on commit 583e8fd

Please sign in to comment.