mirror of
https://github.com/netchx/netch.git
synced 2026-03-14 17:43:18 +08:00
[Redirector] Optimize code
This commit is contained in:
@@ -74,7 +74,7 @@ bool DNSHandler::IsDNS(PSOCKADDR_IN6 target)
|
||||
void DNSHandler::CreateHandler(ENDPOINT_ID id, PSOCKADDR_IN6 target, const char* packet, int length, PNF_UDP_OPTIONS options)
|
||||
{
|
||||
SOCKADDR_IN6 remote;
|
||||
auto buffer = new char[length];
|
||||
auto buffer = new char[length]();
|
||||
auto option = (PNF_UDP_OPTIONS)new char[sizeof(NF_UDP_OPTIONS) + options->optionsLength];
|
||||
|
||||
memcpy(&remote, target, sizeof(SOCKADDR_IN6));
|
||||
|
||||
@@ -309,7 +309,7 @@ void udpSend(ENDPOINT_ID id, const unsigned char* target, const char* buffer, in
|
||||
return;
|
||||
}
|
||||
|
||||
auto data = (PNF_UDP_OPTIONS)new char[sizeof(NF_UDP_OPTIONS) + options->optionsLength];
|
||||
auto data = (PNF_UDP_OPTIONS)new char[sizeof(NF_UDP_OPTIONS) + options->optionsLength]();
|
||||
memcpy(data, options, sizeof(NF_UDP_OPTIONS) + options->optionsLength - 1);
|
||||
|
||||
thread(udpBeginReceive, id, udpConn, data).detach();
|
||||
|
||||
@@ -53,7 +53,7 @@ void ipSend(const char* buffer, int length, PNF_IP_PACKET_OPTIONS options)
|
||||
return;
|
||||
}
|
||||
|
||||
auto data = new BYTE[length];
|
||||
auto data = new BYTE[length]();
|
||||
memcpy(data, buffer, length);
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user