Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines with new year.
[simgrid.git] / teshsuite / msg / app-bittorrent / connection.c
index 24a27d7..59f1b53 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -9,12 +9,12 @@
 #include <xbt/sysdep.h>
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(msg_peers);
 
-connection_t connection_new(const char* id)
+connection_t connection_new(int id)
 {
   connection_t connection = xbt_new(s_connection_t, 1);
 
-  connection->id              = xbt_strdup(id);
-  connection->mailbox         = xbt_strdup(id);
+  connection->id              = id;
+  connection->mailbox         = bprintf("%d", id);
   connection->bitfield        = 0;
   connection->current_piece   = -1;
   connection->interested      = 0;
@@ -35,12 +35,11 @@ void connection_add_speed_value(connection_t connection, double speed)
 void connection_free(void* data)
 {
   connection_t co = (connection_t)data;
-  xbt_free(co->id);
   xbt_free(co->mailbox);
   xbt_free(co);
 }
 
-int connection_has_piece(connection_t connection, unsigned int piece)
+int connection_has_piece(const s_connection_t* connection, unsigned int piece)
 {
   return (connection->bitfield & 1U << piece);
 }