Free memory allocated with malloc()
This commit is contained in:
		@@ -5,6 +5,7 @@
 | 
			
		||||
 | 
			
		||||
/* Destructor - closes any open sockets */
 | 
			
		||||
Client::~Client() {
 | 
			
		||||
	free(dest);
 | 
			
		||||
	close(this->other_socket);
 | 
			
		||||
	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;
 | 
			
		||||
		network = inet_to_int(results->ai_family);
 | 
			
		||||
		free(port_str);
 | 
			
		||||
	} else {
 | 
			
		||||
	        create_addr(network,address,port,remote_addr_struct);
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								main.cpp
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								main.cpp
									
									
									
									
									
								
							@@ -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 */
 | 
			
		||||
					std::cout << "NOTHING RECEIVED" << std::endl;
 | 
			
		||||
				}
 | 
			
		||||
				free(response_array);
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			/* Check to see if peer has quit the game */
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,7 @@
 | 
			
		||||
 | 
			
		||||
/* Destructor - closes any open sockets */
 | 
			
		||||
Server::~Server() {
 | 
			
		||||
	free(dest);
 | 
			
		||||
	close(this->other_socket);
 | 
			
		||||
	close(this->sock_fd);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user