Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/lz4/inc/ZipLZ4.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#ifdef __cplusplus
extern "C" {
#endif
void R__zipLZ4(int cxlevel, int *srcsize, char *src, int *tgtsize, char *tgt, int *irep);
void R__unzipLZ4(int *srcsize, unsigned char *src, int *tgtsize, unsigned char *tgt, int *irep);
void R__zipLZ4(int cxlevel, int *srcsize, const char *src, int *tgtsize, char *tgt, int *irep);
void R__unzipLZ4(int *srcsize, const unsigned char *src, int *tgtsize, unsigned char *tgt, int *irep);
#ifdef __cplusplus
}
#endif
Expand Down
6 changes: 3 additions & 3 deletions core/lz4/src/ZipLZ4.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static const int kChecksumOffset = 2 + 1 + 3 + 3;
static const int kChecksumSize = sizeof(XXH64_canonical_t);
static const int kHeaderSize = kChecksumOffset + kChecksumSize;

void R__zipLZ4(int cxlevel, int *srcsize, char *src, int *tgtsize, char *tgt, int *irep)
void R__zipLZ4(int cxlevel, int *srcsize, const char *src, int *tgtsize, char *tgt, int *irep)
{
int LZ4_version = LZ4_versionNumber();
uint64_t out_size; /* compressed size */
Expand Down Expand Up @@ -84,7 +84,7 @@ void R__zipLZ4(int cxlevel, int *srcsize, char *src, int *tgtsize, char *tgt, in
*irep = (int)returnStatus + kHeaderSize;
}

void R__unzipLZ4(int *srcsize, unsigned char *src, int *tgtsize, unsigned char *tgt, int *irep)
void R__unzipLZ4(int *srcsize, const unsigned char *src, int *tgtsize, unsigned char *tgt, int *irep)
{
// NOTE: We don't check that srcsize / tgtsize is reasonable or within the ROOT-imposed limits.
// This is assumed to be handled by the upper layers.
Expand All @@ -111,7 +111,7 @@ void R__unzipLZ4(int *srcsize, unsigned char *src, int *tgtsize, unsigned char *
// extra function call costs? NOTE that ROOT limits the buffer size to 16MB.
XXH64_hash_t checksumResult = XXH64(src + kHeaderSize, inputBufferSize, 0);
XXH64_hash_t checksumFromFile =
XXH64_hashFromCanonical(reinterpret_cast<XXH64_canonical_t *>(src + kChecksumOffset));
XXH64_hashFromCanonical(reinterpret_cast<const XXH64_canonical_t *>(src + kChecksumOffset));

if (R__unlikely(checksumFromFile != checksumResult)) {
fprintf(
Expand Down
4 changes: 2 additions & 2 deletions core/lzma/inc/ZipLZMA.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
extern "C" {
#endif

void R__zipLZMA(int cxlevel, int *srcsize, char *src, int *tgtsize, char *tgt, int *irep);
void R__zipLZMA(int cxlevel, int *srcsize, const char *src, int *tgtsize, char *tgt, int *irep);

void R__unzipLZMA(int *srcsize, unsigned char *src, int *tgtsize, unsigned char *tgt, int *irep);
void R__unzipLZMA(int *srcsize, const unsigned char *src, int *tgtsize, unsigned char *tgt, int *irep);

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions core/lzma/src/ZipLZMA.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

static const int kHeaderSize = 9;

void R__zipLZMA(int cxlevel, int *srcsize, char *src, int *tgtsize, char *tgt, int *irep)
void R__zipLZMA(int cxlevel, int *srcsize, const char *src, int *tgtsize, char *tgt, int *irep)
{
uint64_t out_size; /* compressed size */
unsigned in_size = (unsigned) (*srcsize);
Expand Down Expand Up @@ -99,7 +99,7 @@ void R__zipLZMA(int cxlevel, int *srcsize, char *src, int *tgtsize, char *tgt, i
*irep = (int)stream.total_out + kHeaderSize;
}

void R__unzipLZMA(int *srcsize, unsigned char *src, int *tgtsize, unsigned char *tgt, int *irep)
void R__unzipLZMA(int *srcsize, const unsigned char *src, int *tgtsize, unsigned char *tgt, int *irep)
{
lzma_stream stream = LZMA_STREAM_INIT;
lzma_ret returnStatus;
Expand Down
16 changes: 11 additions & 5 deletions core/zip/inc/RZip.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,26 @@
#ifndef ROOT_RZip
#define ROOT_RZip

namespace ROOT::Internal {

constexpr int kZipHeaderSize = 9; ///< Number of bytes of the ROOT compression block header

} // namespace ROOT::Internal

extern "C" unsigned long R__crc32(unsigned long crc, const unsigned char *buf, unsigned int len);

extern "C" unsigned long R__memcompress(char *tgt, unsigned long tgtsize, char *src, unsigned long srcsize);
extern "C" unsigned long R__memcompress(char *tgt, unsigned long tgtsize, const char *src, unsigned long srcsize);

extern "C" void R__zipMultipleAlgorithm(int cxlevel, int *srcsize, char *src, int *tgtsize, char *tgt, int *irep,
extern "C" void R__zipMultipleAlgorithm(int cxlevel, int *srcsize, const char *src, int *tgtsize, char *tgt, int *irep,
ROOT::RCompressionSetting::EAlgorithm::EValues algorithm);


extern "C" ROOT::RCompressionSetting::EAlgorithm::EValues R__getCompressionAlgorithm(const unsigned char *buf,
extern "C" ROOT::RCompressionSetting::EAlgorithm::EValues R__getCompressionAlgorithm(const unsigned char *buf,
size_t bufsize);

extern "C" void R__unzip(int *srcsize, unsigned char *src, int *tgtsize, unsigned char *tgt, int *irep);
extern "C" void R__unzip(int *srcsize, const unsigned char *src, int *tgtsize, unsigned char *tgt, int *irep);

extern "C" int R__unzip_header(int *srcsize, unsigned char *src, int *tgtsize);
extern "C" int R__unzip_header(int *srcsize, const unsigned char *src, int *tgtsize);

enum { kMAXZIPBUF = 0xffffff }; // 16 MB

Expand Down
2 changes: 1 addition & 1 deletion core/zip/src/Bits.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ int R__seekable()
* the first six bytes (method and crc).
*/

ulg R__memcompress(char *tgt, ulg tgtsize, char *src, ulg srcsize)
ulg R__memcompress(char *tgt, ulg tgtsize, const char *src, ulg srcsize)
/* char *tgt, *src; target and source buffers */
/* ulg tgtsize, srcsize; target and source sizes */
{
Expand Down
7 changes: 4 additions & 3 deletions core/zip/src/Bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ struct bits_internal_state {
* are always zero.
*/

char *in_buf, *out_buf;
const char *in_buf;
char *out_buf;
/* Current input and output buffers. in_buf is used only for in-memory
* compression.
*/
Expand Down Expand Up @@ -239,13 +240,13 @@ int R__mem_read OF((bits_internal_state *state, char *b, unsigned bsize)
*/
/* char *tgt, *src; target and source buffers */
/* ulg tgtsize, srcsize; target and source sizes */
ulg R__memcompress(char *tgt, ulg tgtsize, char *src, ulg srcsize);
ulg R__memcompress(char *tgt, ulg tgtsize, const char *src, ulg srcsize);


/**
* Decompress a deflated entry.
*/
int R__Inflate(uch** ibufptr, long* ibufcnt, uch** obufptr, long* obufcnt);
int R__Inflate(const uch** ibufptr, long* ibufcnt, uch** obufptr, long* obufcnt);

#ifdef __cplusplus
} // extern "C"
Expand Down
34 changes: 18 additions & 16 deletions core/zip/src/RZip.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
/**
* Forward decl's
*/
static void R__zipOld(int cxlevel, int *srcsize, char *src, int *tgtsize, char *tgrt, int *irep);
static void R__zipZLIB(int cxlevel, int *srcsize, char *src, int *tgtsize, char *tgrt, int *irep);
static void R__unzipZLIB(int *srcsize, unsigned char *src, int *tgtsize, unsigned char *tgt, int *irep);
static void R__zipOld(int cxlevel, int *srcsize, const char *src, int *tgtsize, char *tgrt, int *irep);
static void R__zipZLIB(int cxlevel, int *srcsize, const char *src, int *tgtsize, char *tgrt, int *irep);
static void R__unzipZLIB(int *srcsize, const unsigned char *src, int *tgtsize, unsigned char *tgt, int *irep);

/* ===========================================================================
R__ZipMode is used to select the compression algorithm when R__zip is called
Expand Down Expand Up @@ -76,7 +76,8 @@ unsigned long R__crc32(unsigned long crc, const unsigned char* buf, unsigned int
/* 1 = zlib */
/* 2 = lzma */
/* 3 = old */
void R__zipMultipleAlgorithm(int cxlevel, int *srcsize, char *src, int *tgtsize, char *tgt, int *irep, ROOT::RCompressionSetting::EAlgorithm::EValues compressionAlgorithm)
void R__zipMultipleAlgorithm(int cxlevel, int *srcsize, const char *src, int *tgtsize, char *tgt, int *irep,
ROOT::RCompressionSetting::EAlgorithm::EValues compressionAlgorithm)
{
*irep = 0;

Expand Down Expand Up @@ -117,7 +118,7 @@ void R__zipMultipleAlgorithm(int cxlevel, int *srcsize, char *src, int *tgtsize,
// The very old algorithm for backward compatibility
// 0 for selecting with R__ZipMode in a backward compatible way
// 3 for selecting in other cases
static void R__zipOld(int cxlevel, int *srcsize, char *src, int *tgtsize, char *tgt, int *irep)
static void R__zipOld(int cxlevel, int *srcsize, const char *src, int *tgtsize, char *tgt, int *irep)
{
int method = Z_DEFLATED;
bits_internal_state state;
Expand Down Expand Up @@ -178,7 +179,7 @@ static void R__zipOld(int cxlevel, int *srcsize, char *src, int *tgtsize, char *
/**
* Compress buffer contents using the venerable zlib algorithm.
*/
static void R__zipZLIB(int cxlevel, int *srcsize, char *src, int *tgtsize, char *tgt, int *irep)
static void R__zipZLIB(int cxlevel, int *srcsize, const char *src, int *tgtsize, char *tgt, int *irep)
{
int err;
int method = Z_DEFLATED;
Expand Down Expand Up @@ -246,32 +247,32 @@ static void R__zipZLIB(int cxlevel, int *srcsize, char *src, int *tgtsize, char
* Below are the routines for unzipping (inflating) buffers.
*/

static int is_valid_header_zlib(unsigned char *src)
static int is_valid_header_zlib(const unsigned char *src)
{
return src[0] == 'Z' && src[1] == 'L' && src[2] == Z_DEFLATED;
}

static int is_valid_header_old(unsigned char *src)
static int is_valid_header_old(const unsigned char *src)
{
return src[0] == 'C' && src[1] == 'S' && src[2] == Z_DEFLATED;
}

static int is_valid_header_lzma(unsigned char *src)
static int is_valid_header_lzma(const unsigned char *src)
{
return src[0] == 'X' && src[1] == 'Z' && src[2] == 0;
}

static int is_valid_header_lz4(unsigned char *src)
static int is_valid_header_lz4(const unsigned char *src)
{
return src[0] == 'L' && src[1] == '4';
}

static int is_valid_header_zstd(unsigned char *src)
static int is_valid_header_zstd(const unsigned char *src)
{
return src[0] == 'Z' && src[1] == 'S' && src[2] == '\1';
}

static int is_valid_header(unsigned char *src)
static int is_valid_header(const unsigned char *src)
{
return is_valid_header_zlib(src) || is_valid_header_old(src) || is_valid_header_lzma(src) ||
is_valid_header_lz4(src) || is_valid_header_zstd(src);
Expand All @@ -296,7 +297,7 @@ ROOT::RCompressionSetting::EAlgorithm::EValues R__getCompressionAlgorithm(const
return ROOT::RCompressionSetting::EAlgorithm::kUndefined;
}

int R__unzip_header(int *srcsize, uch *src, int *tgtsize)
int R__unzip_header(int *srcsize, const uch *src, int *tgtsize)
{
// Reads header envelope, and determines target size.
// Returns 0 in case of success.
Expand Down Expand Up @@ -336,10 +337,11 @@ int R__unzip_header(int *srcsize, uch *src, int *tgtsize)
***********************************************************************/
// N.B. (Brian) - I have kept the original note out of complete awe of the
// age of the original code...
void R__unzip(int *srcsize, uch *src, int *tgtsize, uch *tgt, int *irep)
void R__unzip(int *srcsize, const uch *src, int *tgtsize, uch *tgt, int *irep)
{
long isize;
uch *ibufptr, *obufptr;
const uch *ibufptr;
uch *obufptr;
long ibufcnt, obufcnt;

*irep = 0L;
Expand Down Expand Up @@ -407,7 +409,7 @@ void R__unzip(int *srcsize, uch *src, int *tgtsize, uch *tgt, int *irep)
*irep = isize;
}

void R__unzipZLIB(int *srcsize, unsigned char *src, int *tgtsize, unsigned char *tgt, int *irep)
void R__unzipZLIB(int *srcsize, const unsigned char *src, int *tgtsize, unsigned char *tgt, int *irep)
{
z_stream stream; /* decompression stream */
int err = 0;
Expand Down
4 changes: 2 additions & 2 deletions core/zstd/inc/ZipZSTD.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#ifdef __cplusplus
extern "C" {
#endif
void R__zipZSTD(int cxlevel, int *srcsize, char *src, int *tgtsize, char *tgt, int *irep);
void R__unzipZSTD(int *srcsize, unsigned char *src, int *tgtsize, unsigned char *tgt, int *irep);
void R__zipZSTD(int cxlevel, int *srcsize, const char *src, int *tgtsize, char *tgt, int *irep);
void R__unzipZSTD(int *srcsize, const unsigned char *src, int *tgtsize, unsigned char *tgt, int *irep);
#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions core/zstd/src/ZipZSTD.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static const int kHeaderSize = 9;

static const size_t errorCodeSmallBuffer = (size_t)-70;

void R__zipZSTD(int cxlevel, int *srcsize, char *src, int *tgtsize, char *tgt, int *irep)
void R__zipZSTD(int cxlevel, int *srcsize, const char *src, int *tgtsize, char *tgt, int *irep)
{
using Ctx_ptr = std::unique_ptr<ZSTD_CCtx, decltype(&ZSTD_freeCCtx)>;
Ctx_ptr fCtx{ZSTD_createCCtx(), &ZSTD_freeCCtx};
Expand Down Expand Up @@ -58,7 +58,7 @@ void R__zipZSTD(int cxlevel, int *srcsize, char *src, int *tgtsize, char *tgt, i
tgt[8] = (inflate_size >> 16) & 0xff;
}

void R__unzipZSTD(int *srcsize, unsigned char *src, int *tgtsize, unsigned char *tgt, int *irep)
void R__unzipZSTD(int *srcsize, const unsigned char *src, int *tgtsize, unsigned char *tgt, int *irep)
{
using Ctx_ptr = std::unique_ptr<ZSTD_DCtx, decltype(&ZSTD_freeDCtx)>;
Ctx_ptr fCtx{ZSTD_createDCtx(), &ZSTD_freeDCtx};
Expand Down
2 changes: 2 additions & 0 deletions io/io/inc/TKey.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class TKey : public TNamed {
TKey(const TKey&) = delete; // TKey objects are not copiable.
TKey& operator=(const TKey&) = delete; // TKey objects are not copiable.

Int_t UnzipObject(char *targetBuffer, const char *compressedBuffer) const;

protected:
Int_t fVersion; ///< Key version identifier
Int_t fNbytes; ///< Number of bytes for the object on file
Expand Down
2 changes: 1 addition & 1 deletion io/io/src/TBufferJSON.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ TString TBufferJSON::zipJSON(const char *json)

int nout = 0;

R__zipMultipleAlgorithm(ROOT::RCompressionSetting::ELevel::kDefaultZLIB, &srcsize, (char *)json, &tgtsize, (char *) buf.data(), &nout, ROOT::RCompressionSetting::EAlgorithm::kZLIB);
R__zipMultipleAlgorithm(ROOT::RCompressionSetting::ELevel::kDefaultZLIB, &srcsize, json, &tgtsize, (char *) buf.data(), &nout, ROOT::RCompressionSetting::EAlgorithm::kZLIB);

return TBase64::Encode(buf.data(), nout);
}
Expand Down
Loading
Loading