static TCP_con *get_tcp_connection(const TCP_Connections *tcp_c, int tcp_connections_number) { if (tcp_connections_number_not_valid(tcp_c, tcp_connections_number)) return 0; return &tcp_c->tcp_connections[tcp_connections_number]; }
/* Wipe a connection. * * return -1 on failure. * return 0 on success. */ static int wipe_tcp_connection(TCP_Connections *tcp_c, int tcp_connections_number) { if (tcp_connections_number_not_valid(tcp_c, tcp_connections_number)) return -1; uint32_t i; memset(&(tcp_c->tcp_connections[tcp_connections_number]), 0 , sizeof(TCP_con)); for (i = tcp_c->tcp_connections_length; i != 0; --i) { if (tcp_c->tcp_connections[i - 1].status != TCP_CONN_NONE) break; } if (tcp_c->tcp_connections_length != i) { tcp_c->tcp_connections_length = i; TCP_con *temp_pointer; realloc_tox_array(tcp_c->tcp_connections, sizeof(TCP_con), tcp_c->tcp_connections_length, temp_pointer); } return 0; }
/* Wipe a connection. * * return -1 on failure. * return 0 on success. */ static int wipe_tcp_connection(TCP_Connections *tcp_c, int tcp_connections_number) { if (tcp_connections_number_not_valid(tcp_c, tcp_connections_number)) { return -1; } uint32_t i; memset(&tcp_c->tcp_connections[tcp_connections_number], 0, sizeof(TCP_con)); for (i = tcp_c->tcp_connections_length; i != 0; --i) { if (tcp_c->tcp_connections[i - 1].status != TCP_CONN_NONE) { break; } } if (tcp_c->tcp_connections_length != i) { tcp_c->tcp_connections_length = i; realloc_TCP_con(&tcp_c->tcp_connections, tcp_c->tcp_connections_length); } return 0; }