connection_id can be negative, so it shouldn't be uint32_t.

This commit is contained in:
Anony Moose 2013-08-26 20:36:32 +00:00
parent 79f759049b
commit fefa2bdea0
3 changed files with 6 additions and 10 deletions

View File

@ -139,7 +139,7 @@ static inline uint8_t tox_array_push_ptr(tox_array *arr, uint8_t *item)
{
arr->data = realloc(arr->data, arr->elem_size * (arr->len+1));
if (arr->data == NULL)
if (arr->data == NULL) /* didn't call tox_array_init() */
return 0;
if (item != NULL)

View File

@ -98,7 +98,7 @@ int new_connection(Lossless_UDP *ludp, IP_Port ip_port)
if (connect != -1)
return connect;
uint32_t connection_id = -1;
int connection_id = -1;
tox_array_for_each(&ludp->connections, Connection, tmp) {
if (tmp.status == 0) {
connection_id = tmp_i;
@ -147,7 +147,7 @@ static int new_inconnection(Lossless_UDP *ludp, IP_Port ip_port)
if (getconnection_id(ludp, ip_port) != -1)
return -1;
uint32_t connection_id = -1;
int connection_id = -1;
tox_array_for_each(&ludp->connections, Connection, tmp) {
if (tmp.status == 0) {
connection_id = tmp_i;
@ -384,7 +384,7 @@ static int send_handshake(Lossless_UDP *ludp, IP_Port ip_port, uint32_t handshak
return sendpacket(ludp->net->sock, ip_port, packet, sizeof(packet));
}
static int send_SYNC(Lossless_UDP *ludp, uint32_t connection_id)
static int send_SYNC(Lossless_UDP *ludp, int connection_id)
{
Connection *connection = &tox_array_get(&ludp->connections, connection_id, Connection);
@ -413,7 +413,7 @@ static int send_SYNC(Lossless_UDP *ludp, uint32_t connection_id)
}
static int send_data_packet(Lossless_UDP *ludp, uint32_t connection_id, uint32_t packet_num)
static int send_data_packet(Lossless_UDP *ludp, int connection_id, uint32_t packet_num)
{
Connection *connection = &tox_array_get(&ludp->connections, connection_id, Connection);
@ -428,7 +428,7 @@ static int send_data_packet(Lossless_UDP *ludp, uint32_t connection_id, uint32_t
}
/* sends 1 data packet */
static int send_DATA(Lossless_UDP *ludp, uint32_t connection_id)
static int send_DATA(Lossless_UDP *ludp, int connection_id)
{
Connection *connection = &tox_array_get(&ludp->connections, connection_id, Connection);
int ret;

View File

@ -122,10 +122,6 @@ typedef struct {
Networking_Core *net;
tox_array connections;
//kk Connection *connections;
//kk uint32_t connections_length; /* Length of connections array */
//kk uint32_t connections_number; /* Number of connections in connections array */
/* table of random numbers used in handshake_id. */
uint32_t randtable[6][256];