From 6eae3d5ad7cb984314c6ff2b12756bbc4324af54 Mon Sep 17 00:00:00 2001 From: notsecure Date: Tue, 20 May 2014 09:21:26 -0400 Subject: [PATCH] fixed some mistakes --- toxcore/TCP_server.c | 6 +++--- toxcore/list.c | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/toxcore/TCP_server.c b/toxcore/TCP_server.c index fe912f94..a47f74e2 100644 --- a/toxcore/TCP_server.c +++ b/toxcore/TCP_server.c @@ -140,6 +140,9 @@ static int add_accepted(TCP_Server *TCP_server, TCP_Secure_Connection *con) return -1; } + if (!list_add(&TCP_server->accepted_key_list, con->public_key, index)) + return -1; + memcpy(&TCP_server->accepted_connection_array[index], con, sizeof(TCP_Secure_Connection)); TCP_server->accepted_connection_array[index].status = TCP_STATUS_CONFIRMED; ++TCP_server->num_accepted_connections; @@ -147,9 +150,6 @@ static int add_accepted(TCP_Server *TCP_server, TCP_Secure_Connection *con) TCP_server->accepted_connection_array[index].last_pinged = unix_time(); TCP_server->accepted_connection_array[index].ping_id = 0; - if (!list_add(&TCP_server->accepted_key_list, con->public_key, index)) - return -1; - return index; } diff --git a/toxcore/list.c b/toxcore/list.c index 2b21eec8..2904d15b 100644 --- a/toxcore/list.c +++ b/toxcore/list.c @@ -189,6 +189,8 @@ int list_remove(LIST *list, void *data, int id) return 0; } + list->n--; + memmove(list->data + i * list->size, list->data + (i + 1) * list->size, (list->n - i) * list->size); memmove(&list->ids[i], &list->ids[i + 1], (list->n - i) * sizeof(int));