diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-09-18 01:31:55 +0100 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-09-24 21:53:50 +0100 |
commit | 15cb4261665bab4ef02a5b1b9db48b9477c9b87a (patch) | |
tree | d0c40a45afa19fff26ce1eb5bb703e18a9acdd4a /toxcore/TCP_server.c | |
parent | 0d347c2b2e69aa09b079f6daaa00007fef4fe52f (diff) |
Make toxcore code C++ compatible.
It is still C code, so still compatible with C compilers as well. This
change lets us see more clearly where implicit conversions occur by
making them explicit.
Diffstat (limited to 'toxcore/TCP_server.c')
-rw-r--r-- | toxcore/TCP_server.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/toxcore/TCP_server.c b/toxcore/TCP_server.c index 7e348fa5..a078da94 100644 --- a/toxcore/TCP_server.c +++ b/toxcore/TCP_server.c | |||
@@ -113,8 +113,9 @@ static int realloc_connection(TCP_Server *TCP_server, uint32_t num) | |||
113 | return 0; | 113 | return 0; |
114 | } | 114 | } |
115 | 115 | ||
116 | TCP_Secure_Connection *new_connections = realloc(TCP_server->accepted_connection_array, | 116 | TCP_Secure_Connection *new_connections = (TCP_Secure_Connection *)realloc( |
117 | num * sizeof(TCP_Secure_Connection)); | 117 | TCP_server->accepted_connection_array, |
118 | num * sizeof(TCP_Secure_Connection)); | ||
118 | 119 | ||
119 | if (new_connections == NULL) { | 120 | if (new_connections == NULL) { |
120 | return -1; | 121 | return -1; |
@@ -407,25 +408,25 @@ static int send_pending_data(TCP_Secure_Connection *con) | |||
407 | */ | 408 | */ |
408 | static bool add_priority(TCP_Secure_Connection *con, const uint8_t *packet, uint16_t size, uint16_t sent) | 409 | static bool add_priority(TCP_Secure_Connection *con, const uint8_t *packet, uint16_t size, uint16_t sent) |
409 | { | 410 | { |
410 | TCP_Priority_List *p = con->priority_queue_end, *new; | 411 | TCP_Priority_List *p = con->priority_queue_end; |
411 | new = malloc(sizeof(TCP_Priority_List) + size); | 412 | TCP_Priority_List *new_list = (TCP_Priority_List *)malloc(sizeof(TCP_Priority_List) + size); |
412 | 413 | ||
413 | if (!new) { | 414 | if (!new_list) { |
414 | return 0; | 415 | return 0; |
415 | } | 416 | } |
416 | 417 | ||
417 | new->next = NULL; | 418 | new_list->next = NULL; |
418 | new->size = size; | 419 | new_list->size = size; |
419 | new->sent = sent; | 420 | new_list->sent = sent; |
420 | memcpy(new->data, packet, size); | 421 | memcpy(new_list->data, packet, size); |
421 | 422 | ||
422 | if (p) { | 423 | if (p) { |
423 | p->next = new; | 424 | p->next = new_list; |
424 | } else { | 425 | } else { |
425 | con->priority_queue_start = new; | 426 | con->priority_queue_start = new_list; |
426 | } | 427 | } |
427 | 428 | ||
428 | con->priority_queue_end = new; | 429 | con->priority_queue_end = new_list; |
429 | return 1; | 430 | return 1; |
430 | } | 431 | } |
431 | 432 | ||
@@ -779,7 +780,7 @@ static int rm_connection_index(TCP_Server *TCP_server, TCP_Secure_Connection *co | |||
779 | 780 | ||
780 | static int handle_onion_recv_1(void *object, IP_Port dest, const uint8_t *data, uint16_t length) | 781 | static int handle_onion_recv_1(void *object, IP_Port dest, const uint8_t *data, uint16_t length) |
781 | { | 782 | { |
782 | TCP_Server *TCP_server = object; | 783 | TCP_Server *TCP_server = (TCP_Server *)object; |
783 | uint32_t index = dest.ip.ip6.uint32[0]; | 784 | uint32_t index = dest.ip.ip6.uint32[0]; |
784 | 785 | ||
785 | if (index >= TCP_server->size_accepted_connections) { | 786 | if (index >= TCP_server->size_accepted_connections) { |
@@ -1034,13 +1035,13 @@ TCP_Server *new_TCP_server(uint8_t ipv6_enabled, uint16_t num_sockets, const uin | |||
1034 | return NULL; | 1035 | return NULL; |
1035 | } | 1036 | } |
1036 | 1037 | ||
1037 | TCP_Server *temp = calloc(1, sizeof(TCP_Server)); | 1038 | TCP_Server *temp = (TCP_Server *)calloc(1, sizeof(TCP_Server)); |
1038 | 1039 | ||
1039 | if (temp == NULL) { | 1040 | if (temp == NULL) { |
1040 | return NULL; | 1041 | return NULL; |
1041 | } | 1042 | } |
1042 | 1043 | ||
1043 | temp->socks_listening = calloc(num_sockets, sizeof(sock_t)); | 1044 | temp->socks_listening = (sock_t *)calloc(num_sockets, sizeof(sock_t)); |
1044 | 1045 | ||
1045 | if (temp->socks_listening == NULL) { | 1046 | if (temp->socks_listening == NULL) { |
1046 | free(temp); | 1047 | free(temp); |