summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/main.c b/main.c
index b7654ae..c9cfb04 100644
--- a/main.c
+++ b/main.c
@@ -490,7 +490,7 @@ int handle_frame(protocol_frame *frame)
490 * It checks for basic inconsistiencies and allocates the 490 * It checks for basic inconsistiencies and allocates the
491 * protocol_frame structure. 491 * protocol_frame structure.
492 */ 492 */
493int parse_lossless_packet(Tox *tox, int32_t friendnumber, const uint8_t *data, uint32_t len, void *sender_uc) 493int parse_lossless_packet(Tox *tox, int32_t friendnumber, const uint8_t *data, uint32_t len, void *tmp)
494{ 494{
495 protocol_frame *frame = NULL; 495 protocol_frame *frame = NULL;
496 496
@@ -525,7 +525,7 @@ int parse_lossless_packet(Tox *tox, int32_t friendnumber, const uint8_t *data, u
525 frame->connid = INT16_AT(data, 4); 525 frame->connid = INT16_AT(data, 4);
526 frame->data_length = INT16_AT(data, 6); 526 frame->data_length = INT16_AT(data, 6);
527 frame->data = (uint8_t *)(data + PROTOCOL_BUFFER_OFFSET); 527 frame->data = (uint8_t *)(data + PROTOCOL_BUFFER_OFFSET);
528 frame->friendnumber = *((uint32_t*)sender_uc); 528 frame->friendnumber = friendnumber;
529 log_printf(L_DEBUG, "Got protocol frame magic 0x%x type 0x%x from friend %d\n", frame->magic, frame->packet_type, frame->friendnumber); 529 log_printf(L_DEBUG, "Got protocol frame magic 0x%x type 0x%x from friend %d\n", frame->magic, frame->packet_type, frame->friendnumber);
530 530
531 if(len < frame->data_length + PROTOCOL_BUFFER_OFFSET) 531 if(len < frame->data_length + PROTOCOL_BUFFER_OFFSET)
@@ -654,7 +654,6 @@ void accept_friend_request(Tox *tox, const uint8_t *public_key, const uint8_t *d
654{ 654{
655 unsigned char tox_printable_id[TOX_FRIEND_ADDRESS_SIZE * 2 + 1]; 655 unsigned char tox_printable_id[TOX_FRIEND_ADDRESS_SIZE * 2 + 1];
656 int32_t friendnumber; 656 int32_t friendnumber;
657 int32_t *friendnumber_ptr = NULL;
658 657
659 log_printf(L_DEBUG, "Got friend request\n"); 658 log_printf(L_DEBUG, "Got friend request\n");
660 659
@@ -664,17 +663,7 @@ void accept_friend_request(Tox *tox, const uint8_t *public_key, const uint8_t *d
664 id_to_string(tox_printable_id, public_key); 663 id_to_string(tox_printable_id, public_key);
665 log_printf(L_INFO, "Accepted friend request from %s as %d\n", tox_printable_id, friendnumber); 664 log_printf(L_INFO, "Accepted friend request from %s as %d\n", tox_printable_id, friendnumber);
666 665
667 /* TODO: this is not freed right now, we're leaking 4 bytes per contact (OMG!) */ 666 tox_lossless_packet_registerhandler(tox, friendnumber, (PROTOCOL_MAGIC_V1)>>8, parse_lossless_packet, NULL);
668 friendnumber_ptr = malloc(sizeof(int32_t));
669 if(!friendnumber_ptr)
670 {
671 log_printf(L_ERROR, "Could not allocate memory for friendnumber_ptr\n");
672 return;
673 }
674
675 *friendnumber_ptr = friendnumber;
676
677 tox_lossless_packet_registerhandler(tox, friendnumber, (PROTOCOL_MAGIC_V1)>>8, parse_lossless_packet, (void*)friendnumber_ptr);
678} 667}
679 668
680void cleanup(int status, void *tmp) 669void cleanup(int status, void *tmp)