mirror of
				https://gitlab.com/klmp200/LO41.git
				synced 2025-10-31 01:03:05 +00:00 
			
		
		
		
	leaks ;-;
This commit is contained in:
		| @@ -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_nb = residents->get_size(residents) + visitors->get_size(visitors) + ELEVATOR_NB; | ||||||
| 			this->threads = malloc_or_die(sizeof(pthread_t*) * this->threads_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)); | 				this->threads[i] = malloc_or_die(sizeof(pthread_t)); | ||||||
|  | 			} | ||||||
|  |  | ||||||
| 			pthread_mutex_lock(&this->mutex_active_passengers); | 			pthread_mutex_lock(&this->mutex_active_passengers); | ||||||
| 			pthread_mutex_lock(&this->mutex_threads); | 			pthread_mutex_lock(&this->mutex_threads); | ||||||
| @@ -95,7 +97,7 @@ void _free__SharedData(THIS(SharedData)){ | |||||||
| 	if (this->threads != NULL){ | 	if (this->threads != NULL){ | ||||||
| 		for (i=0; i<this->threads_nb; i++) { | 		for (i=0; i<this->threads_nb; i++) { | ||||||
| 			if (this->threads[i] != NULL) { | 			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); | 				pthread_kill(*this->threads[i], SIGUSR1); | ||||||
| 			} | 			} | ||||||
| 			free(this->threads[i]); | 			free(this->threads[i]); | ||||||
| @@ -107,6 +109,8 @@ void _free__SharedData(THIS(SharedData)){ | |||||||
|  |  | ||||||
| 	pthread_mutex_unlock(&this->mutex_active_passengers); | 	pthread_mutex_unlock(&this->mutex_active_passengers); | ||||||
| 	pthread_mutex_destroy(&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); | 	free(this); | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user