mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 04:45:45 +00:00
Bug 1420673: Use UniquePtr to store nsHostResolver.addr r=valentin
MozReview-Commit-ID: Arrm0stdtNL --HG-- extra : rebase_source : 24c9c9db0bfcfce435b244119b088e90cb6c4061 extra : source : 1bade2a7b61167128f9cef4b543dd0bcef6295e4
This commit is contained in:
parent
a1cf236d7a
commit
91d2efb8b5
@ -157,7 +157,7 @@ nsDNSRecord::GetNextAddr(uint16_t port, NetAddr *addr)
|
||||
// attempt to reresolve it failed.
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
memcpy(addr, mHostRecord->addr, sizeof(NetAddr));
|
||||
memcpy(addr, mHostRecord->addr.get(), sizeof(NetAddr));
|
||||
mDone = true;
|
||||
}
|
||||
|
||||
@ -202,7 +202,7 @@ nsDNSRecord::GetAddresses(nsTArray<NetAddr> & aAddressArray)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
NetAddr *addr = aAddressArray.AppendElement(NetAddr());
|
||||
memcpy(addr, mHostRecord->addr, sizeof(NetAddr));
|
||||
memcpy(addr, mHostRecord->addr.get(), sizeof(NetAddr));
|
||||
if (addr->raw.family == AF_INET) {
|
||||
addr->inet.port = 0;
|
||||
} else if (addr->raw.family == AF_INET6) {
|
||||
|
@ -232,7 +232,6 @@ nsHostRecord::~nsHostRecord()
|
||||
{
|
||||
Telemetry::Accumulate(Telemetry::DNS_BLACKLIST_COUNT, mBlacklistedCount);
|
||||
delete addr_info;
|
||||
delete addr;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -353,7 +352,7 @@ nsHostRecord::SizeOfIncludingThis(MallocSizeOf mallocSizeOf) const
|
||||
|
||||
n += SizeOfResolveHostCallbackListExcludingHead(&callbacks, mallocSizeOf);
|
||||
n += addr_info ? addr_info->SizeOfIncludingThis(mallocSizeOf) : 0;
|
||||
n += mallocSizeOf(addr);
|
||||
n += mallocSizeOf(addr.get());
|
||||
|
||||
n += mBlacklistedItems.ShallowSizeOfExcludingThis(mallocSizeOf);
|
||||
for (size_t i = 0; i < mBlacklistedItems.Length(); i++) {
|
||||
@ -818,8 +817,8 @@ nsHostResolver::ResolveHost(const char *host,
|
||||
LOG((" Host is IP Literal [%s].\n", host));
|
||||
// ok, just copy the result into the host record, and be done
|
||||
// with it! ;-)
|
||||
he->rec->addr = new NetAddr();
|
||||
PRNetAddrToNetAddr(&tempAddr, he->rec->addr);
|
||||
he->rec->addr = MakeUnique<NetAddr>();
|
||||
PRNetAddrToNetAddr(&tempAddr, he->rec->addr.get());
|
||||
// put reference to host record on stack...
|
||||
Telemetry::Accumulate(Telemetry::DNS_LOOKUP_METHOD2,
|
||||
METHOD_LITERAL);
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "mozilla/net/DNS.h"
|
||||
#include "mozilla/net/DashboardTypes.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
class nsHostResolver;
|
||||
class nsHostRecord;
|
||||
@ -75,7 +76,7 @@ public:
|
||||
Mutex addr_info_lock;
|
||||
int addr_info_gencnt; /* generation count of |addr_info| */
|
||||
mozilla::net::AddrInfo *addr_info;
|
||||
mozilla::net::NetAddr *addr;
|
||||
mozilla::UniquePtr<mozilla::net::NetAddr> addr;
|
||||
bool negative; /* True if this record is a cache of a failed lookup.
|
||||
Negative cache entries are valid just like any other
|
||||
(though never for more than 60 seconds), but a use
|
||||
|
Loading…
Reference in New Issue
Block a user