fix: massive memory leak (not all fixed) and added more test cases

This commit is contained in:
AfonsoCMSousa
2026-03-24 11:15:28 +00:00
parent a1f868c27b
commit 7cdecceef2
3 changed files with 43 additions and 9 deletions
+3 -1
View File
@@ -6,6 +6,7 @@
#include <stdatomic.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#define G_CONSTANT 1.98f
@@ -148,7 +149,7 @@ void collision_update(Particle *particles, unsigned long long count, float resti
void *t_update(void *args) {
Physics_params *params = (Physics_params *)args;
while (params->exit != 1) {
while (!params->exit) {
pthread_mutex_lock(params->mutex);
while (params->run == 0) {
pthread_cond_wait(params->cond, params->mutex); // sleeps here
@@ -202,6 +203,7 @@ void *t_update(void *args) {
pthread_barrier_wait(params->barrier);
}
printf("INFO: Thread %llu exiting\n", params->thread_id);
return NULL;
}