first-free-port : suppression paramètre inutile get_listening_ports

This commit is contained in:
Ahurac 2023-12-10 15:30:36 +01:00
parent 98c8239009
commit 1662776d6b

View file

@ -23,7 +23,8 @@ static void print_error(char *name, const char *message) {
/** /**
* Get all the listening TCP ports * Get all the listening TCP ports
*/ */
static unsigned short *get_listening_ports(unsigned short *listening_ports, FILE *tcp_table_fptr) { static unsigned short *get_listening_ports(FILE *tcp_table_fptr) {
unsigned short *listening_ports = malloc(BLOCKS_TO_ALLOC * sizeof(short));
char line[TCP_TABLE_LINE_LENGTH]; char line[TCP_TABLE_LINE_LENGTH];
char delimiter[] = " "; char delimiter[] = " ";
unsigned short len = 0; unsigned short len = 0;
@ -99,8 +100,7 @@ int main(int argc, char *argv[]) {
return errno; return errno;
} }
unsigned short *listening_ports = malloc(PORTS_BLOCKS_TO_ALLOW * sizeof(unsigned short)); unsigned short *listening_ports = get_listening_ports(tcp_table_fptr);
listening_ports = get_listening_ports(listening_ports, tcp_table_fptr);
if (fclose(tcp_table_fptr) != 0) { if (fclose(tcp_table_fptr) != 0) {
print_error(argv[0], "can't close the TCP table."); print_error(argv[0], "can't close the TCP table.");