mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 953296 - Convert trivial ScopedDelete{Ptr,Array} uses to UniquePtr in mozglue/linker/. (More remain, but they're less trivial to change.) r=glandium
--HG-- extra : rebase_source : 7af7ff2daa70ff3aedaac91d3898bcd90a402162
This commit is contained in:
parent
f7ef4836ca
commit
8c69dfae30
@ -9,7 +9,11 @@
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
|
||||
#include "Mappable.h"
|
||||
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <linux/ashmem.h>
|
||||
#endif
|
||||
@ -63,28 +67,28 @@ MappableExtractFile::Create(const char *name, Zip *zip, Zip::Stream *stream)
|
||||
"not extracting");
|
||||
return nullptr;
|
||||
}
|
||||
mozilla::ScopedDeleteArray<char> path;
|
||||
path = new char[strlen(cachePath) + strlen(name) + 2];
|
||||
sprintf(path, "%s/%s", cachePath, name);
|
||||
mozilla::UniquePtr<char[]> path;
|
||||
path.reset(new char[strlen(cachePath) + strlen(name) + 2]);
|
||||
sprintf(path.get(), "%s/%s", cachePath, name);
|
||||
struct stat cacheStat;
|
||||
if (stat(path, &cacheStat) == 0) {
|
||||
if (stat(path.get(), &cacheStat) == 0) {
|
||||
struct stat zipStat;
|
||||
stat(zip->GetName(), &zipStat);
|
||||
if (cacheStat.st_mtime > zipStat.st_mtime) {
|
||||
DEBUG_LOG("Reusing %s", static_cast<char *>(path));
|
||||
return MappableFile::Create(path);
|
||||
DEBUG_LOG("Reusing %s", static_cast<char *>(path.get()));
|
||||
return MappableFile::Create(path.get());
|
||||
}
|
||||
}
|
||||
DEBUG_LOG("Extracting to %s", static_cast<char *>(path));
|
||||
DEBUG_LOG("Extracting to %s", static_cast<char *>(path.get()));
|
||||
AutoCloseFD fd;
|
||||
fd = open(path, O_TRUNC | O_RDWR | O_CREAT | O_NOATIME,
|
||||
S_IRUSR | S_IWUSR);
|
||||
fd = open(path.get(), O_TRUNC | O_RDWR | O_CREAT | O_NOATIME,
|
||||
S_IRUSR | S_IWUSR);
|
||||
if (fd == -1) {
|
||||
ERROR("Couldn't open %s to decompress library", path.get());
|
||||
return nullptr;
|
||||
}
|
||||
AutoUnlinkFile file;
|
||||
file = path.forget();
|
||||
file = path.release();
|
||||
if (stream->GetType() == Zip::Stream::DEFLATE) {
|
||||
if (ftruncate(fd, stream->GetUncompressedSize()) == -1) {
|
||||
ERROR("Couldn't ftruncate %s to decompress library", file.get());
|
||||
@ -575,8 +579,7 @@ MappableSeekableZStream::stats(const char *when, const char *name) const
|
||||
name, when, static_cast<size_t>(chunkAvailNum), nEntries);
|
||||
|
||||
size_t len = 64;
|
||||
mozilla::ScopedDeleteArray<char> map;
|
||||
map = new char[len + 3];
|
||||
mozilla::UniquePtr<char[]> map(new char[len + 3]);
|
||||
map[0] = '[';
|
||||
|
||||
for (size_t i = 0, j = 1; i < nEntries; i++, j++) {
|
||||
@ -584,7 +587,7 @@ MappableSeekableZStream::stats(const char *when, const char *name) const
|
||||
if ((j == len) || (i == nEntries - 1)) {
|
||||
map[j + 1] = ']';
|
||||
map[j + 2] = '\0';
|
||||
DEBUG_LOG("%s", static_cast<char *>(map));
|
||||
DEBUG_LOG("%s", static_cast<char *>(map.get()));
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <errno.h>
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Scoped.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "SeekableZStream.h"
|
||||
#include "Utils.h"
|
||||
#include "Logging.h"
|
||||
@ -466,7 +467,7 @@ bool GetSize(const char *str, size_t *out)
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
mozilla::ScopedDeletePtr<SzipAction> action;
|
||||
mozilla::UniquePtr<SzipAction> action;
|
||||
char **firstArg;
|
||||
bool compress = true;
|
||||
size_t chunkSize = 0;
|
||||
@ -528,7 +529,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
if (compress) {
|
||||
action = new SzipCompress(chunkSize, filter, dictSize);
|
||||
action.reset(new SzipCompress(chunkSize, filter, dictSize));
|
||||
} else {
|
||||
if (chunkSize) {
|
||||
ERROR("-c is incompatible with -d");
|
||||
@ -538,7 +539,7 @@ int main(int argc, char* argv[])
|
||||
ERROR("-D is incompatible with -d");
|
||||
return 1;
|
||||
}
|
||||
action = new SzipDecompress();
|
||||
action.reset(new SzipDecompress());
|
||||
}
|
||||
|
||||
std::stringstream tmpOutStream;
|
||||
|
Loading…
Reference in New Issue
Block a user