Skip to content
Snippets Groups Projects
Commit 8049520e authored by leonard.beck's avatar leonard.beck :zzz:
Browse files

fixed leaks

parent a79ef408
No related branches found
No related tags found
No related merge requests found
...@@ -40,7 +40,7 @@ int stopped_wheels(machine mas){ ...@@ -40,7 +40,7 @@ int stopped_wheels(machine mas){
int main() int main()
{ {
int wheel_turn = 4; int wheel_turn = WHEEL_NB + 1;
bool paid = false; bool paid = false;
bool quit=false; bool quit=false;
pthread_t threads[WHEEL_NB + 1]; pthread_t threads[WHEEL_NB + 1];
...@@ -114,5 +114,10 @@ int main() ...@@ -114,5 +114,10 @@ int main()
} }
} while(!quit); } while(!quit);
sem_destroy(&(mas.semaphore));
for (int i = 0; i < WHEEL_NB; i++) {
pthread_mutex_destroy(&(mas.wheels[i].lock));
}
return 0; return 0;
} }
...@@ -12,9 +12,9 @@ typedef struct roue{ ...@@ -12,9 +12,9 @@ typedef struct roue{
int current_px; int current_px;
// used to synchronize cache with memory so display is always up to date // used to synchronize cache with memory so display is always up to date
pthread_mutex_t lock; pthread_mutex_t lock;
// used to make the thread wait when the wheel is not spinning
sem_t* semaphore; sem_t* semaphore;
// used to securely exit the game
bool* end; bool* end;
} wheel; } wheel;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment