CMS 3D CMS Logo

Namespaces | Functions
CStringStream.cc File Reference
#include <cassert>
#include <cstring>
#include <memory>
#include "zlib.h"
#include "Alignment/Geners/interface/BZ2Handle.hh"
#include "Alignment/Geners/interface/CStringStream.hh"
#include "Alignment/Geners/interface/IOException.hh"

Go to the source code of this file.

Namespaces

 gs
 

Functions

static void doBZ2Compression (const char *data, const unsigned long long len, const bool defl, bz_stream &strm, char *buffer, const unsigned long long bufLen, std::ostream &sink)
 
static void doZlibCompression (const char *data, const unsigned long long len, const bool defl, z_stream_s &strm, char *buffer, const unsigned long long bufLen, std::ostream &sink)
 

Function Documentation

◆ doBZ2Compression()

static void doBZ2Compression ( const char *  data,
const unsigned long long  len,
const bool  defl,
bz_stream &  strm,
char *  buffer,
const unsigned long long  bufLen,
std::ostream &  sink 
)
static

Definition at line 43 of file CStringStream.cc.

References cms::cuda::assert(), edmScanValgrind::buffer, data, and mps_update::status.

49  {
50  assert(buffer);
51  assert(bufLen);
52 
53  int status = BZ_OK;
54  strm.next_in = const_cast<char *>(data);
55  strm.avail_in = len;
56  do {
57  strm.next_out = buffer;
58  strm.avail_out = bufLen;
59  status = defl ? BZ2_bzCompress(&strm, BZ_FINISH) : BZ2_bzDecompress(&strm);
60  assert(status == BZ_OK || status == BZ_STREAM_END);
61  const unsigned have = bufLen - strm.avail_out;
62  sink.write(buffer, have);
63  if (sink.fail())
64  throw gs::IOWriteFailure("In gs::doBZ2Compression: sink stream failure");
65  } while (status != BZ_STREAM_END);
66 }
assert(be >=bs)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ doZlibCompression()

static void doZlibCompression ( const char *  data,
const unsigned long long  len,
const bool  defl,
z_stream_s &  strm,
char *  buffer,
const unsigned long long  bufLen,
std::ostream &  sink 
)
static

Definition at line 11 of file CStringStream.cc.

References cms::cuda::assert(), edmScanValgrind::buffer, data, and mps_update::status.

17  {
18  assert(buffer);
19  assert(bufLen);
20 
21  int status = Z_OK;
22  strm.next_in = reinterpret_cast<Bytef *>(const_cast<char *>(data));
23  strm.avail_in = len;
24  do {
25  strm.next_out = reinterpret_cast<Bytef *>(buffer);
26  strm.avail_out = bufLen;
27  status = defl ? deflate(&strm, Z_FINISH) : inflate(&strm, Z_NO_FLUSH);
28  assert(status == Z_OK || status == Z_STREAM_END);
29  const unsigned have = bufLen - strm.avail_out;
30  sink.write(buffer, have);
31  if (sink.fail())
32  throw gs::IOWriteFailure("In gs::doZlibCompression: sink stream failure");
33  } while (strm.avail_out == 0);
34 
35  if (defl) {
36  assert(strm.avail_in == 0);
37  assert(status == Z_STREAM_END);
38  assert(deflateReset(&strm) == Z_OK);
39  } else
40  assert(inflateReset(&strm) == Z_OK);
41 }
assert(be >=bs)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80