mirror of
https://gitlab.com/klmp200/LO41.git
synced 2024-11-21 16:23:22 +00:00
leaks ;-;
This commit is contained in:
parent
e2beb598a9
commit
bb1610d4fb
@ -41,8 +41,10 @@ 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++)
|
||||
for (i=0; i < this->threads_nb; i++){
|
||||
this->threads[i] = NULL;
|
||||
this->threads[i] = malloc_or_die(sizeof(pthread_t));
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&this->mutex_active_passengers);
|
||||
pthread_mutex_lock(&this->mutex_threads);
|
||||
@ -95,7 +97,7 @@ void _free__SharedData(THIS(SharedData)){
|
||||
if (this->threads != NULL){
|
||||
for (i=0; i<this->threads_nb; i++) {
|
||||
if (this->threads[i] != NULL) {
|
||||
printf("Quitting thread %d\n", (int) this->threads[i]);
|
||||
printf("Quitting thread %d\n", (*(int*) this->threads[i]));
|
||||
pthread_kill(*this->threads[i], SIGUSR1);
|
||||
}
|
||||
free(this->threads[i]);
|
||||
@ -107,6 +109,8 @@ void _free__SharedData(THIS(SharedData)){
|
||||
|
||||
pthread_mutex_unlock(&this->mutex_active_passengers);
|
||||
pthread_mutex_destroy(&this->mutex_active_passengers);
|
||||
pthread_mutex_unlock(&this->mutex_threads);
|
||||
pthread_mutex_destroy(&this->mutex_threads);
|
||||
|
||||
free(this);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user