mirror of
https://github.com/roytam1/basilisk55.git
synced 2026-05-26 15:02:46 +00:00
5959ed8aa3
Bug 1430557. r=longsonr, a=lizzard (d2012d4) Bug 1416529. r=mcmanus, a=ritu (6c616d7) Bug 1324042 - Fix trimmedOffsets arithmetic in GetRenderedText(). r=mats, a=RyanVM (0625e66) Bug 1428947 - Check plane width & stride constraints. r=mattwoodrow, a=ritu (af26fd8) Bug 1334465 - Set mIPCClosed to true before calling SendDeleteSelf in order to avoid race. r=bagder, a=ritu (48000c3) Bug 1334465 - Make HttpChannelParent::mIPCClosed atomic. r=bagder, a=ritu (40f3b6c) Bug 1398021 - Update lz4 to version 1.8.0. r=froydnj, a=RyanVM (9324e57) Bug 1388020. r=nical, a=RyanVM (25eb3e4) Bug 1437087 - Call Disconnect on Unlink of cycle collector. r=masayuki, a=RyanVM (439bf2f) Bug 1437507 - Fix JSObject::setFlags to call ensureShape before checking for dictionary mode. r=jandem, a=RyanVM (fd3a371) Bug 1440926 - Use overflow-checking math when computing Big5 max length. r=emk, a=RyanVM (72ee25b) Bug 1440775 - Make fetch API force-cache and only-if-cached use VALIDATE_NEVER instead of LOAD_FROM_CACHE. r=mayhemer, a=RyanVM (322d7d2) Bug 1425520. r=smaug, a=abillings (112a59e) Bug 1437450 - Disable Ion no-clone optimization for regexps if the graph contains try blocks. r=nbp, a=RyanVM (c78bbff)
79 lines
2.3 KiB
C++
79 lines
2.3 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "mozilla/Compression.h"
|
|
#include "mozilla/CheckedInt.h"
|
|
|
|
// Without including <string>, MSVC 2015 complains about e.g. the impossibility
|
|
// to convert `const void* const` to `void*` when calling memchr from
|
|
// corecrt_memory.h.
|
|
#include <string>
|
|
|
|
using namespace mozilla::Compression;
|
|
|
|
namespace {
|
|
|
|
extern "C" {
|
|
|
|
#include "lz4.c"
|
|
|
|
}
|
|
|
|
}/* anonymous namespace */
|
|
|
|
/* Our wrappers */
|
|
|
|
size_t
|
|
LZ4::compress(const char* aSource, size_t aInputSize, char* aDest)
|
|
{
|
|
CheckedInt<int> inputSizeChecked = aInputSize;
|
|
MOZ_ASSERT(inputSizeChecked.isValid());
|
|
return LZ4_compress_default(aSource, aDest, inputSizeChecked.value(),
|
|
LZ4_compressBound(inputSizeChecked.value()));
|
|
}
|
|
|
|
size_t
|
|
LZ4::compressLimitedOutput(const char* aSource, size_t aInputSize, char* aDest,
|
|
size_t aMaxOutputSize)
|
|
{
|
|
CheckedInt<int> inputSizeChecked = aInputSize;
|
|
MOZ_ASSERT(inputSizeChecked.isValid());
|
|
CheckedInt<int> maxOutputSizeChecked = aMaxOutputSize;
|
|
MOZ_ASSERT(maxOutputSizeChecked.isValid());
|
|
return LZ4_compress_default(aSource, aDest, inputSizeChecked.value(),
|
|
maxOutputSizeChecked.value());
|
|
}
|
|
|
|
bool
|
|
LZ4::decompress(const char* aSource, char* aDest, size_t aOutputSize)
|
|
{
|
|
CheckedInt<int> outputSizeChecked = aOutputSize;
|
|
MOZ_ASSERT(outputSizeChecked.isValid());
|
|
int ret = LZ4_decompress_fast(aSource, aDest, outputSizeChecked.value());
|
|
return ret >= 0;
|
|
}
|
|
|
|
bool
|
|
LZ4::decompress(const char* aSource, size_t aInputSize, char* aDest,
|
|
size_t aMaxOutputSize, size_t* aOutputSize)
|
|
{
|
|
CheckedInt<int> maxOutputSizeChecked = aMaxOutputSize;
|
|
MOZ_ASSERT(maxOutputSizeChecked.isValid());
|
|
CheckedInt<int> inputSizeChecked = aInputSize;
|
|
MOZ_ASSERT(inputSizeChecked.isValid());
|
|
|
|
int ret = LZ4_decompress_safe(aSource, aDest, inputSizeChecked.value(),
|
|
maxOutputSizeChecked.value());
|
|
if (ret >= 0) {
|
|
*aOutputSize = ret;
|
|
return true;
|
|
}
|
|
|
|
*aOutputSize = 0;
|
|
return false;
|
|
}
|
|
|