зеркало из https://github.com/mozilla/gecko-dev.git
Back out f341384014d4, redness not trivially fixable. r=bustage affecting a CLOSED TREE
This commit is contained in:
Родитель
90d8bb6fe0
Коммит
a1c757bd34
|
@ -23,9 +23,6 @@
|
|||
#include "SeekableZStream.h"
|
||||
#include "Logging.h"
|
||||
|
||||
using mozilla::MakeUnique;
|
||||
using mozilla::UniquePtr;
|
||||
|
||||
Mappable *
|
||||
MappableFile::Create(const char *path)
|
||||
{
|
||||
|
@ -70,8 +67,8 @@ MappableExtractFile::Create(const char *name, Zip *zip, Zip::Stream *stream)
|
|||
"not extracting");
|
||||
return nullptr;
|
||||
}
|
||||
UniquePtr<char[]> path =
|
||||
MakeUnique<char[]>(strlen(cachePath) + strlen(name) + 2);
|
||||
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.get(), &cacheStat) == 0) {
|
||||
|
@ -90,7 +87,8 @@ MappableExtractFile::Create(const char *name, Zip *zip, Zip::Stream *stream)
|
|||
ERROR("Couldn't open %s to decompress library", path.get());
|
||||
return nullptr;
|
||||
}
|
||||
AutoUnlinkFile file(path.release());
|
||||
AutoUnlinkFile file;
|
||||
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());
|
||||
|
@ -149,7 +147,7 @@ MappableExtractFile::Create(const char *name, Zip *zip, Zip::Stream *stream)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
return new MappableExtractFile(fd.forget(), Move(file));
|
||||
return new MappableExtractFile(fd.forget(), file.forget());
|
||||
}
|
||||
|
||||
MappableExtractFile::~MappableExtractFile()
|
||||
|
@ -396,7 +394,8 @@ MappableSeekableZStream::Create(const char *name, Zip *zip,
|
|||
if (!mappable->buffer)
|
||||
return nullptr;
|
||||
|
||||
mappable->chunkAvail = MakeUnique<unsigned char[]>(mappable->zStream.GetChunksNum());
|
||||
mappable->chunkAvail = new unsigned char[mappable->zStream.GetChunksNum()];
|
||||
memset(mappable->chunkAvail, 0, mappable->zStream.GetChunksNum());
|
||||
|
||||
return mappable.forget();
|
||||
}
|
||||
|
@ -580,7 +579,7 @@ MappableSeekableZStream::stats(const char *when, const char *name) const
|
|||
name, when, static_cast<size_t>(chunkAvailNum), nEntries);
|
||||
|
||||
size_t len = 64;
|
||||
UniquePtr<char[]> map = MakeUnique<char[]>(len + 3);
|
||||
mozilla::UniquePtr<char[]> map(new char[len + 3]);
|
||||
map[0] = '[';
|
||||
|
||||
for (size_t i = 0, j = 1; i < nEntries; i++, j++) {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "Zip.h"
|
||||
#include "SeekableZStream.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/Scoped.h"
|
||||
#include "zlib.h"
|
||||
|
||||
/**
|
||||
|
@ -123,21 +123,24 @@ public:
|
|||
|
||||
virtual Kind GetKind() const { return MAPPABLE_EXTRACT_FILE; };
|
||||
private:
|
||||
MappableExtractFile(int fd, AutoUnlinkFile path)
|
||||
: MappableFile(fd), path(Move(path)), pid(getpid()) { }
|
||||
MappableExtractFile(int fd, char *path)
|
||||
: MappableFile(fd), path(path), pid(getpid()) { }
|
||||
|
||||
/**
|
||||
* AutoUnlinkFile keeps track of a file name and removes (unlinks) the file
|
||||
* AutoUnlinkFile keeps track or a file name and removes (unlinks) the file
|
||||
* when the instance is destroyed.
|
||||
*/
|
||||
struct UnlinkFile
|
||||
struct AutoUnlinkFileTraits: public mozilla::ScopedDeleteArrayTraits<char>
|
||||
{
|
||||
void operator()(char *value) {
|
||||
static void release(char *value)
|
||||
{
|
||||
if (!value)
|
||||
return;
|
||||
unlink(value);
|
||||
delete [] value;
|
||||
mozilla::ScopedDeleteArrayTraits<char>::release(value);
|
||||
}
|
||||
};
|
||||
typedef mozilla::UniquePtr<char[], UnlinkFile> AutoUnlinkFile;
|
||||
typedef mozilla::Scoped<AutoUnlinkFileTraits> AutoUnlinkFile;
|
||||
|
||||
/* Extracted file */
|
||||
AutoUnlinkFile path;
|
||||
|
@ -177,7 +180,7 @@ private:
|
|||
mozilla::RefPtr<Zip> zip;
|
||||
|
||||
/* Decompression buffer */
|
||||
mozilla::UniquePtr<_MappableBuffer> buffer;
|
||||
mozilla::ScopedDeletePtr<_MappableBuffer> buffer;
|
||||
|
||||
/* Zlib data */
|
||||
z_stream zStream;
|
||||
|
@ -217,7 +220,7 @@ private:
|
|||
mozilla::RefPtr<Zip> zip;
|
||||
|
||||
/* Decompression buffer */
|
||||
mozilla::UniquePtr<_MappableBuffer> buffer;
|
||||
mozilla::ScopedDeletePtr<_MappableBuffer> buffer;
|
||||
|
||||
/* Seekable ZStream */
|
||||
SeekableZStream zStream;
|
||||
|
@ -260,7 +263,7 @@ private:
|
|||
|
||||
/* Array keeping track of which chunks have already been decompressed.
|
||||
* Each value is the number of pages decompressed for the given chunk. */
|
||||
mozilla::UniquePtr<unsigned char[]> chunkAvail;
|
||||
mozilla::ScopedDeleteArray<unsigned char> chunkAvail;
|
||||
|
||||
/* Number of chunks that have already been decompressed. */
|
||||
mozilla::Atomic<size_t> chunkAvailNum;
|
||||
|
|
Загрузка…
Ссылка в новой задаче