Free memory allocated with malloc()

master
Aadhavan Srinivasan 9 months ago
parent 1641cef13b
commit b6439bf7d5

@ -5,6 +5,7 @@
/* Destructor - closes any open sockets */ /* Destructor - closes any open sockets */
Client::~Client() { Client::~Client() {
free(dest);
close(this->other_socket); close(this->other_socket);
close(this->sock_fd); close(this->sock_fd);
} }

@ -133,6 +133,7 @@ SOCKET create_remote (int network,char transport, const char* address,int port,s
} }
remote_addr_struct = (struct sockaddr_storage *)results->ai_addr; remote_addr_struct = (struct sockaddr_storage *)results->ai_addr;
network = inet_to_int(results->ai_family); network = inet_to_int(results->ai_family);
free(port_str);
} else { } else {
create_addr(network,address,port,remote_addr_struct); create_addr(network,address,port,remote_addr_struct);
} }

@ -392,6 +392,7 @@ int main(int argc, char** argv) {
/* If the response is NULL, that means it timed-out. In this case, there's no value to print */ /* If the response is NULL, that means it timed-out. In this case, there's no value to print */
std::cout << "NOTHING RECEIVED" << std::endl; std::cout << "NOTHING RECEIVED" << std::endl;
} }
free(response_array);
} }
/* Check to see if peer has quit the game */ /* Check to see if peer has quit the game */

@ -12,6 +12,7 @@
/* Destructor - closes any open sockets */ /* Destructor - closes any open sockets */
Server::~Server() { Server::~Server() {
free(dest);
close(this->other_socket); close(this->other_socket);
close(this->sock_fd); close(this->sock_fd);
} }

Loading…
Cancel
Save