summaryrefslogtreecommitdiff
path: root/toxcore/net_crypto.c
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2014-01-13 20:11:54 -0500
committerirungentoo <irungentoo@gmail.com>2014-01-13 20:11:54 -0500
commit878762a8e4ec6873daa29bcf32a9416844943ae2 (patch)
tree2047f3790f7663be4c2ede59b9f9f47aa07fb776 /toxcore/net_crypto.c
parent675487936e5424021e1cef677643f469a5ed03ec (diff)
Added functions to add/remove friends in onion_client.
Added a tiny optimization to net_crypto.
Diffstat (limited to 'toxcore/net_crypto.c')
-rw-r--r--toxcore/net_crypto.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c
index aec2a9e7..a6c3ecd9 100644
--- a/toxcore/net_crypto.c
+++ b/toxcore/net_crypto.c
@@ -473,8 +473,9 @@ static int getcryptconnection_id(Net_Crypto *c, uint8_t *public_key)
473/* Set the size of the friend list to numfriends. 473/* Set the size of the friend list to numfriends.
474 * 474 *
475 * return -1 if realloc fails. 475 * return -1 if realloc fails.
476 * return 0 if it succeeds.
476 */ 477 */
477int realloc_cryptoconnection(Net_Crypto *c, uint32_t num) 478static int realloc_cryptoconnection(Net_Crypto *c, uint32_t num)
478{ 479{
479 if (num == 0) { 480 if (num == 0) {
480 free(c->crypto_connections); 481 free(c->crypto_connections);
@@ -604,8 +605,11 @@ int crypto_kill(Net_Crypto *c, int crypt_connection_id)
604 break; 605 break;
605 } 606 }
606 607
607 c->crypto_connections_length = i; 608 if (c->crypto_connections_length != i) {
608 realloc_cryptoconnection(c, c->crypto_connections_length); 609 c->crypto_connections_length = i;
610 realloc_cryptoconnection(c, c->crypto_connections_length);
611 }
612
609 return 0; 613 return 0;
610 } 614 }
611 615