Realloc apparently doesn't always behave like free() if size is zero.

This commit is contained in:
irungentoo 2013-08-19 07:15:56 -04:00
parent 88986f793a
commit 17890b1f61
2 changed files with 12 additions and 0 deletions

View File

@ -704,6 +704,12 @@ int DHT_delfriend(uint8_t *client_id)
CLIENT_ID_SIZE );
}
if (num_friends == 0) {
free(friends_list);
friends_list = NULL;
return 0;
}
temp = realloc(friends_list, sizeof(Friend) * (num_friends));
if (temp == NULL)

View File

@ -319,6 +319,12 @@ static void free_connections(void)
if (connections_length == i)
return;
if (i == 0) {
free(connections);
connections = NULL;
return;
}
Connection *temp;
temp = realloc(connections, sizeof(Connection) * i);