diff --git a/src/first-free-port.c b/src/first-free-port.c index 35005dc..320b14e 100644 --- a/src/first-free-port.c +++ b/src/first-free-port.c @@ -23,7 +23,8 @@ static void print_error(char *name, const char *message) { /** * 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 delimiter[] = " "; unsigned short len = 0; @@ -99,8 +100,7 @@ int main(int argc, char *argv[]) { return errno; } - unsigned short *listening_ports = malloc(PORTS_BLOCKS_TO_ALLOW * sizeof(unsigned short)); - listening_ports = get_listening_ports(listening_ports, tcp_table_fptr); + unsigned short *listening_ports = get_listening_ports(tcp_table_fptr); if (fclose(tcp_table_fptr) != 0) { print_error(argv[0], "can't close the TCP table.");