1
0
mirror of https://gitlab.com/klmp200/LO41.git synced 2024-12-28 18:51:11 +00:00

FUCK YOU

This commit is contained in:
Antoine Bartuccio 2018-06-22 03:18:44 +02:00
parent bb1610d4fb
commit 6b7bb7e119
Signed by: klmp200
GPG Key ID: E7245548C53F904B

View File

@ -41,10 +41,8 @@ void start_all_threads_SharedData(THIS(SharedData)){
this->threads_nb = residents->get_size(residents) + visitors->get_size(visitors) + ELEVATOR_NB;
this->threads = malloc_or_die(sizeof(pthread_t*) * this->threads_nb);
for (i=0; i < this->threads_nb; i++){
this->threads[i] = NULL;
for (i=0; i < this->threads_nb; i++)
this->threads[i] = malloc_or_die(sizeof(pthread_t));
}
pthread_mutex_lock(&this->mutex_active_passengers);
pthread_mutex_lock(&this->mutex_threads);
@ -99,8 +97,8 @@ void _free__SharedData(THIS(SharedData)){
if (this->threads[i] != NULL) {
printf("Quitting thread %d\n", (*(int*) this->threads[i]));
pthread_kill(*this->threads[i], SIGUSR1);
free(this->threads[i]);
}
free(this->threads[i]);
}
free(this->threads);
}
@ -131,6 +129,7 @@ void decrement_active_passengers_SharedData(THIS(SharedData)){
void unregister_thread_SharedData(THIS(SharedData), int thread_number){
pthread_mutex_lock(&this->mutex_threads);
free(this->threads[thread_number]);
this->threads[thread_number] = NULL;
pthread_mutex_unlock(&this->mutex_threads);
}