Bug 1252191 - use UniquePtr instead of ScopedFreePtr in PoisonIOInterposerMac.cpp; r=aklotz

UniquePtr is more standard than ScopedFreePtr; using standard constructs
whenever possible is preferable.  In this particular case, since we
really just need a chunk of memory, we can allocate a char[] via
MakeUnique.
This commit is contained in:
Nathan Froyd 2016-02-29 10:06:53 -05:00
parent 9aaa4cd2bf
commit d3674aaf6f

View File

@ -13,8 +13,8 @@
#include "mozilla/IOInterposer.h"
#include "mozilla/Mutex.h"
#include "mozilla/ProcessedStack.h"
#include "mozilla/Scoped.h"
#include "mozilla/Telemetry.h"
#include "mozilla/UniquePtrExtensions.h"
#include "nsPrintfCString.h"
#include "mozilla/StackWalk.h"
#include "nsTraceRefcnt.h"
@ -181,7 +181,7 @@ IsValidWrite(int aFd, const void* aWbuf, size_t aCount)
// content. This is needed because dbm doesn't keep track of dirty bits
// and can end up writing the same data to disk twice. Once when the
// user (nss) asks it to sync and once when closing the database.
ScopedFreePtr<void> wbuf2(malloc(aCount));
auto wbuf2 = MakeUniqueFallible<char[]>(aCount);
if (!wbuf2) {
return true;
}
@ -189,11 +189,11 @@ IsValidWrite(int aFd, const void* aWbuf, size_t aCount)
if (pos == -1) {
return true;
}
ssize_t r = read(aFd, wbuf2, aCount);
ssize_t r = read(aFd, wbuf2.get(), aCount);
if (r < 0 || (size_t)r != aCount) {
return true;
}
int cmp = memcmp(aWbuf, wbuf2, aCount);
int cmp = memcmp(aWbuf, wbuf2.get(), aCount);
if (cmp != 0) {
return true;
}