[Aggregator] Delete 'couples' argument

The couple list 'couples' is a global variable, so it is useless to pass
it as an argument to the functions.
This commit is contained in:
Matteo Cypriani 2010-08-06 09:42:22 +02:00
parent 96fb99c951
commit 2c4b182aa7
2 changed files with 21 additions and 21 deletions

View File

@ -70,14 +70,14 @@ void parse_command_line(int argc, char **argv) ;
void check_configuration(void) ; void check_configuration(void) ;
int read_loop(int sockfd) ; int read_loop(int sockfd) ;
void got_couple_info(couple_list **couples, couple_message message) ; void got_couple_info(couple_message message) ;
void free_couple_list(couple_list **couples) ; void free_couple_list(void) ;
#ifdef DEBUG #ifdef DEBUG
void print_couple_list(couple_list *couples) ; void print_couple_list(void) ;
void print_couple_info(couple_info_list *info) ; void print_couple_info(couple_info_list *info) ;
#endif // DEBUG #endif // DEBUG
void* monitor_couple_list(couple_list **couples) ; void* monitor_couples(void) ;
char* ip_bytes_to_string(unsigned char *ip_binary) ; char* ip_bytes_to_string(unsigned char *ip_binary) ;
void print_usage(void) ; void print_usage(void) ;

View File

@ -42,13 +42,13 @@ int main(int argc, char **argv)
/* Set up thread */ /* Set up thread */
pthread_create(&thread, NULL, pthread_create(&thread, NULL,
(void *) &monitor_couple_list, &couples) ; (void *) &monitor_couples, NULL) ;
run = TRUE ; run = TRUE ;
ret = read_loop(sockfd) ; ret = read_loop(sockfd) ;
(void) close(sockfd) ; // Close socket (void) close(sockfd) ; // Close socket
free_couple_list(&couples) ; // Clean list free_couple_list() ;
cfg_free(cfg) ; // Clean configuration cfg_free(cfg) ; // Clean configuration
printf("%s: end.\n", program_name) ; printf("%s: end.\n", program_name) ;
@ -292,7 +292,7 @@ int read_loop(int sockfd)
free(mobile_mac_string) ; free(mobile_mac_string) ;
free(mobile_ip_string) ; free(mobile_ip_string) ;
got_couple_info(&couples, message) ; got_couple_info(message) ;
} }
return ret ; return ret ;
@ -304,7 +304,7 @@ int read_loop(int sockfd)
* Thread function. Monitors the list and sends information to the * Thread function. Monitors the list and sends information to the
* localisation server when the timeout is reached. * localisation server when the timeout is reached.
*/ */
void* monitor_couple_list(couple_list **couples) void* monitor_couples()
{ {
couple_list *couple_ptr, *couple_prev ; couple_list *couple_ptr, *couple_prev ;
couple_info_list *couple_info_ptr ; couple_info_list *couple_info_ptr ;
@ -340,7 +340,7 @@ void* monitor_couple_list(couple_list **couples)
while (run) while (run)
{ {
couple_ptr = *couples ; couple_ptr = couples ;
couple_prev = NULL ; couple_prev = NULL ;
couple_info_ptr = NULL ; couple_info_ptr = NULL ;
gettimeofday(&current_time, NULL) ; gettimeofday(&current_time, NULL) ;
@ -434,7 +434,7 @@ void* monitor_couple_list(couple_list **couples)
// If it is the first couple of the list // If it is the first couple of the list
if (couple_prev == NULL) if (couple_prev == NULL)
*couples = couple_ptr ; // we shift the head couples = couple_ptr ; // we shift the head
else // else we put the next of the previous on the next else // else we put the next of the previous on the next
couple_prev->next = couple_ptr ; couple_prev->next = couple_ptr ;
@ -464,7 +464,7 @@ void* monitor_couple_list(couple_list **couples)
/* /*
* Treats a received packet. * Treats a received packet.
*/ */
void got_couple_info(couple_list **couples, couple_message message) void got_couple_info(couple_message message)
{ {
couple_list *tmp_couple = NULL ; couple_list *tmp_couple = NULL ;
couple_info_list *tmp_info = NULL ; couple_info_list *tmp_info = NULL ;
@ -479,8 +479,8 @@ void got_couple_info(couple_list **couples, couple_message message)
tmp_info->next = NULL ; tmp_info->next = NULL ;
/* Add it in the list */ /* Add it in the list */
tmp_couple = *couples ; tmp_couple = couples ;
if (*couples == NULL) // If the couple list does not exist, if (couples == NULL) // If the couple list does not exist,
{ {
printf("Creating couple list.\n") ; printf("Creating couple list.\n") ;
tmp_couple = malloc(sizeof(couple_list)) ; // create it. tmp_couple = malloc(sizeof(couple_list)) ; // create it.
@ -501,7 +501,7 @@ void got_couple_info(couple_list **couples, couple_message message)
tmp_couple->direction = message.direction ; tmp_couple->direction = message.direction ;
tmp_couple->next = NULL ; tmp_couple->next = NULL ;
tmp_couple->info = tmp_info ; tmp_couple->info = tmp_info ;
*couples = tmp_couple ; couples = tmp_couple ;
} }
else // If the couple list exists already else // If the couple list exists already
@ -552,9 +552,9 @@ void got_couple_info(couple_list **couples, couple_message message)
tmp_couple->y_position = message.y_position ; tmp_couple->y_position = message.y_position ;
tmp_couple->z_position = message.z_position ; tmp_couple->z_position = message.z_position ;
tmp_couple->direction = message.direction ; tmp_couple->direction = message.direction ;
tmp_couple->next = *couples ; tmp_couple->next = couples ;
tmp_couple->info = tmp_info ; tmp_couple->info = tmp_info ;
*couples = tmp_couple ; couples = tmp_couple ;
} }
else // If the couple was found in the list else // If the couple was found in the list
{ {
@ -576,9 +576,9 @@ void got_couple_info(couple_list **couples, couple_message message)
/* Empty the couple list */ /* Empty the couple list */
void free_couple_list(couple_list **couples) void free_couple_list()
{ {
couple_list *couple_ptr = *couples ; couple_list *couple_ptr = couples ;
couple_info_list *couple_info_ptr = NULL ; couple_info_list *couple_info_ptr = NULL ;
if (*couples != NULL) if (*couples != NULL)
@ -593,8 +593,8 @@ void free_couple_list(couple_list **couples)
couple_ptr->info = couple_info_ptr ; couple_ptr->info = couple_info_ptr ;
} }
couple_ptr = couple_ptr->next ; couple_ptr = couple_ptr->next ;
free(*couples) ; free(couples) ;
*couples = couple_ptr ; couples = couple_ptr ;
} }
} }
} }
@ -603,7 +603,7 @@ void free_couple_list(couple_list **couples)
#ifdef DEBUG #ifdef DEBUG
/* Prints the couple list */ /* Prints the couple list */
void print_couple_list(couple_list *couples) void print_couple_list()
{ {
couple_list *couple_ptr = couples ; couple_list *couple_ptr = couples ;
couple_info_list *info_ptr = NULL ; couple_info_list *info_ptr = NULL ;