From 0a4c3d7e2e080dafd66d25f7a5806b89f7be1bcf Mon Sep 17 00:00:00 2001 From: "Coren[m]" Date: Thu, 24 Oct 2013 22:32:28 +0200 Subject: Move unix_time(), id_cpy()/id_eq(), is_timeout() to util.* unix_time(): - returns local value for current epoch - value is updated explicitly with unix_time_update() called at new_DHT()/doMessenger()/do_DHT() is_timeout(): - uses the local value for current epoch id_cpy()/id_eq() => id_copy()/id_equal(): - centralized duplicate definitions - replaced (most) memcpy()/memcmp() of (*, *, CLIENT_ID_SIZE) with id_copy()/id_equal() --- toxcore/friend_requests.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'toxcore/friend_requests.c') diff --git a/toxcore/friend_requests.c b/toxcore/friend_requests.c index c821d998..67977c23 100644 --- a/toxcore/friend_requests.c +++ b/toxcore/friend_requests.c @@ -26,6 +26,7 @@ #endif #include "friend_requests.h" +#include "util.h" /* Try to send a friend request to peer with public_key. * data is the data in the request and length is the length. @@ -102,7 +103,7 @@ static void addto_receivedlist(Friend_Requests *fr, uint8_t *client_id) if (fr->received_requests_index >= MAX_RECEIVED_STORED) fr->received_requests_index = 0; - memcpy(fr->received_requests[fr->received_requests_index], client_id, crypto_box_PUBLICKEYBYTES); + id_copy(fr->received_requests[fr->received_requests_index], client_id); ++fr->received_requests_index; } @@ -115,10 +116,9 @@ static int request_received(Friend_Requests *fr, uint8_t *client_id) { uint32_t i; - for (i = 0; i < MAX_RECEIVED_STORED; ++i) { - if (memcmp(fr->received_requests[i], client_id, crypto_box_PUBLICKEYBYTES) == 0) + for (i = 0; i < MAX_RECEIVED_STORED; ++i) + if (id_equal(fr->received_requests[i], client_id)) return 1; - } return 0; } -- cgit v1.2.3