mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Back out f341384014d4, redness not trivially fixable. r=bustage affecting a CLOSED TREE
This commit is contained in:
parent
a755cbeede
commit
31275a9249
@ -23,9 +23,6 @@
|
|||||||
#include "SeekableZStream.h"
|
#include "SeekableZStream.h"
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
|
|
||||||
using mozilla::MakeUnique;
|
|
||||||
using mozilla::UniquePtr;
|
|
||||||
|
|
||||||
Mappable *
|
Mappable *
|
||||||
MappableFile::Create(const char *path)
|
MappableFile::Create(const char *path)
|
||||||
{
|
{
|
||||||
@ -70,8 +67,8 @@ MappableExtractFile::Create(const char *name, Zip *zip, Zip::Stream *stream)
|
|||||||
"not extracting");
|
"not extracting");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
UniquePtr<char[]> path =
|
mozilla::UniquePtr<char[]> path;
|
||||||
MakeUnique<char[]>(strlen(cachePath) + strlen(name) + 2);
|
path.reset(new char[strlen(cachePath) + strlen(name) + 2]);
|
||||||
sprintf(path.get(), "%s/%s", cachePath, name);
|
sprintf(path.get(), "%s/%s", cachePath, name);
|
||||||
struct stat cacheStat;
|
struct stat cacheStat;
|
||||||
if (stat(path.get(), &cacheStat) == 0) {
|
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());
|
ERROR("Couldn't open %s to decompress library", path.get());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
AutoUnlinkFile file(path.release());
|
AutoUnlinkFile file;
|
||||||
|
file = path.release();
|
||||||
if (stream->GetType() == Zip::Stream::DEFLATE) {
|
if (stream->GetType() == Zip::Stream::DEFLATE) {
|
||||||
if (ftruncate(fd, stream->GetUncompressedSize()) == -1) {
|
if (ftruncate(fd, stream->GetUncompressedSize()) == -1) {
|
||||||
ERROR("Couldn't ftruncate %s to decompress library", file.get());
|
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 nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new MappableExtractFile(fd.forget(), Move(file));
|
return new MappableExtractFile(fd.forget(), file.forget());
|
||||||
}
|
}
|
||||||
|
|
||||||
MappableExtractFile::~MappableExtractFile()
|
MappableExtractFile::~MappableExtractFile()
|
||||||
@ -396,7 +394,8 @@ MappableSeekableZStream::Create(const char *name, Zip *zip,
|
|||||||
if (!mappable->buffer)
|
if (!mappable->buffer)
|
||||||
return nullptr;
|
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();
|
return mappable.forget();
|
||||||
}
|
}
|
||||||
@ -580,7 +579,7 @@ MappableSeekableZStream::stats(const char *when, const char *name) const
|
|||||||
name, when, static_cast<size_t>(chunkAvailNum), nEntries);
|
name, when, static_cast<size_t>(chunkAvailNum), nEntries);
|
||||||
|
|
||||||
size_t len = 64;
|
size_t len = 64;
|
||||||
UniquePtr<char[]> map = MakeUnique<char[]>(len + 3);
|
mozilla::UniquePtr<char[]> map(new char[len + 3]);
|
||||||
map[0] = '[';
|
map[0] = '[';
|
||||||
|
|
||||||
for (size_t i = 0, j = 1; i < nEntries; i++, j++) {
|
for (size_t i = 0, j = 1; i < nEntries; i++, j++) {
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "Zip.h"
|
#include "Zip.h"
|
||||||
#include "SeekableZStream.h"
|
#include "SeekableZStream.h"
|
||||||
#include "mozilla/RefPtr.h"
|
#include "mozilla/RefPtr.h"
|
||||||
#include "mozilla/UniquePtr.h"
|
#include "mozilla/Scoped.h"
|
||||||
#include "zlib.h"
|
#include "zlib.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -123,21 +123,24 @@ public:
|
|||||||
|
|
||||||
virtual Kind GetKind() const { return MAPPABLE_EXTRACT_FILE; };
|
virtual Kind GetKind() const { return MAPPABLE_EXTRACT_FILE; };
|
||||||
private:
|
private:
|
||||||
MappableExtractFile(int fd, AutoUnlinkFile path)
|
MappableExtractFile(int fd, char *path)
|
||||||
: MappableFile(fd), path(Move(path)), pid(getpid()) { }
|
: 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.
|
* 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);
|
unlink(value);
|
||||||
delete [] value;
|
mozilla::ScopedDeleteArrayTraits<char>::release(value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
typedef mozilla::UniquePtr<char[], UnlinkFile> AutoUnlinkFile;
|
typedef mozilla::Scoped<AutoUnlinkFileTraits> AutoUnlinkFile;
|
||||||
|
|
||||||
/* Extracted file */
|
/* Extracted file */
|
||||||
AutoUnlinkFile path;
|
AutoUnlinkFile path;
|
||||||
@ -177,7 +180,7 @@ private:
|
|||||||
mozilla::RefPtr<Zip> zip;
|
mozilla::RefPtr<Zip> zip;
|
||||||
|
|
||||||
/* Decompression buffer */
|
/* Decompression buffer */
|
||||||
mozilla::UniquePtr<_MappableBuffer> buffer;
|
mozilla::ScopedDeletePtr<_MappableBuffer> buffer;
|
||||||
|
|
||||||
/* Zlib data */
|
/* Zlib data */
|
||||||
z_stream zStream;
|
z_stream zStream;
|
||||||
@ -217,7 +220,7 @@ private:
|
|||||||
mozilla::RefPtr<Zip> zip;
|
mozilla::RefPtr<Zip> zip;
|
||||||
|
|
||||||
/* Decompression buffer */
|
/* Decompression buffer */
|
||||||
mozilla::UniquePtr<_MappableBuffer> buffer;
|
mozilla::ScopedDeletePtr<_MappableBuffer> buffer;
|
||||||
|
|
||||||
/* Seekable ZStream */
|
/* Seekable ZStream */
|
||||||
SeekableZStream zStream;
|
SeekableZStream zStream;
|
||||||
@ -260,7 +263,7 @@ private:
|
|||||||
|
|
||||||
/* Array keeping track of which chunks have already been decompressed.
|
/* Array keeping track of which chunks have already been decompressed.
|
||||||
* Each value is the number of pages decompressed for the given chunk. */
|
* 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. */
|
/* Number of chunks that have already been decompressed. */
|
||||||
mozilla::Atomic<size_t> chunkAvailNum;
|
mozilla::Atomic<size_t> chunkAvailNum;
|
||||||
|
Loading…
Reference in New Issue
Block a user