From 878762a8e4ec6873daa29bcf32a9416844943ae2 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Mon, 13 Jan 2014 20:11:54 -0500 Subject: Added functions to add/remove friends in onion_client. Added a tiny optimization to net_crypto. --- toxcore/net_crypto.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'toxcore/net_crypto.c') 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) /* Set the size of the friend list to numfriends. * * return -1 if realloc fails. + * return 0 if it succeeds. */ -int realloc_cryptoconnection(Net_Crypto *c, uint32_t num) +static int realloc_cryptoconnection(Net_Crypto *c, uint32_t num) { if (num == 0) { free(c->crypto_connections); @@ -604,8 +605,11 @@ int crypto_kill(Net_Crypto *c, int crypt_connection_id) break; } - c->crypto_connections_length = i; - realloc_cryptoconnection(c, c->crypto_connections_length); + if (c->crypto_connections_length != i) { + c->crypto_connections_length = i; + realloc_cryptoconnection(c, c->crypto_connections_length); + } + return 0; } -- cgit v1.2.3