X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/6f5f42b500d02eacbefd94f874507bad64139943..0868c23f9325ad81241a6e1df80e804d7f4067b7:/examples/msg/bittorrent/connection.c diff --git a/examples/msg/bittorrent/connection.c b/examples/msg/bittorrent/connection.c index 43ead7cf91..d19d67c9a1 100644 --- a/examples/msg/bittorrent/connection.c +++ b/examples/msg/bittorrent/connection.c @@ -1,5 +1,5 @@ /* Copyright (c) 2012. The SimGrid Team. - * All rights reserved. */ + * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -8,28 +8,33 @@ #include XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(msg_peers); -connection_t connection_new(int id) { - connection_t connection = xbt_new(s_connection_t,1); +connection_t connection_new(int id) +{ + connection_t connection = xbt_new(s_connection_t, 1); - connection->id = id; - connection->mailbox = bprintf("%d",id); - connection->bitfield = NULL; - connection->interested = 0; - connection->am_interested = 0; - connection->choked_upload = 1; - connection->choked_download = 1; - connection->peer_speed = 0; - connection->last_unchoke = 0; + connection->id = id; + connection->mailbox = bprintf("%d", id); + connection->bitfield = NULL; + connection->interested = 0; + connection->am_interested = 0; + connection->choked_upload = 1; + connection->choked_download = 1; + connection->peer_speed = 0; + connection->last_unchoke = 0; - return connection; + return connection; } -void connection_add_speed_value(connection_t connection, double speed) { + +void connection_add_speed_value(connection_t connection, double speed) +{ connection->peer_speed = connection->peer_speed * 0.6 + speed * 0.4; } -void connection_free(void *data) { - connection_t co = (connection_t)data; - xbt_free(co->bitfield); - xbt_free(co->mailbox); - xbt_free(co); + +void connection_free(void *data) +{ + connection_t co = (connection_t) data; + xbt_free(co->bitfield); + xbt_free(co->mailbox); + xbt_free(co); }