Example #1
0
static void
squash_brotli_stream_destroy (void* stream) {
  SquashBrotliStream* s = (SquashBrotliStream*) stream;

  if (((SquashStream*) stream)->stream_type == SQUASH_STREAM_COMPRESS) {
    delete s->compressor;
  } else if (((SquashStream*) stream)->stream_type == SQUASH_STREAM_DECOMPRESS) {
    BrotliDestroyState(s->decompressor);
  } else {
    squash_assert_unreachable();
  }

  squash_stream_destroy (stream);
}
Example #2
0
static void
squash_csc_stream_destroy (void* str) {
  SquashStream* stream = (SquashStream*) str;
  SquashCscStream* s = (SquashCscStream*) str;

  if (stream->stream_type == SQUASH_STREAM_COMPRESS) {
    if (s->ctx.comp != NULL)
      CSCEnc_Destroy (s->ctx.comp);
  } else {
    if (s->ctx.decomp != NULL)
      CSCDec_Destroy (s->ctx.decomp);
  }

  squash_stream_destroy (stream);
}
Example #3
0
static void
squash_lz4f_stream_destroy (void* stream) {
  SquashLZ4FStream* s = (SquashLZ4FStream*) stream;

  if (((SquashStream*) stream)->stream_type == SQUASH_STREAM_COMPRESS) {
    LZ4F_freeCompressionContext(s->data.comp.ctx);

    if (s->data.comp.output_buffer != NULL)
      squash_free (s->data.comp.output_buffer);
  } else {
    LZ4F_freeDecompressionContext(s->data.decomp.ctx);
  }

  squash_stream_destroy (stream);
}
Example #4
0
static void
squash_lz4f_stream_destroy (void* stream) {
  SquashLZ4FStream* s = (SquashLZ4FStream*) stream;
  LZ4F_errorCode_t ec;

  if (((SquashStream*) stream)->stream_type == SQUASH_STREAM_COMPRESS) {
    ec = LZ4F_freeCompressionContext(s->data.comp.ctx);

    if (s->data.comp.output_buffer != NULL)
      free (s->data.comp.output_buffer);
  } else {
    ec = LZ4F_freeDecompressionContext(s->data.decomp.ctx);
  }

  assert (!LZ4F_isError (ec));

  squash_stream_destroy (stream);
}
Example #5
0
	//----------
	Stream & Stream::operator<<(const Finish &) {
		if (this->squashStream == nullptr)
		{
			OFXSQUASH_WARNING << "Stream already finished. You need to make a new one.";
			return* this;
		}

		SquashStatus status;

		do {
			this->squashStream->next_out = this->buffer.data();
			this->squashStream->avail_out = this->buffer.size();

			status = squash_stream_finish(this->squashStream);

			if (status != SQUASH_OK && status != SQUASH_PROCESSING) {
				OFXSQUASH_ERROR << "Processing failed: " << squash_status_to_string(status);
				return * this;
			}

			const size_t outputSize = this->buffer.size() - this->squashStream->avail_out;
			if (outputSize > 0)
			{
				if (this->writeFunction) {
					WriteFunctionArguments args{ this->buffer.data(), outputSize, false };
					this->writeFunction(args);
				}
				else {
					OFXSQUASH_WARNING << "Cannot write stream output. No WriteFunction has been set";
				}
			}
		} while (status == SQUASH_PROCESSING);

		if (this->writeFunction) {
			WriteFunctionArguments args{ nullptr, 0, true };
			this->writeFunction(args);
		}

		squash_stream_destroy(this->squashStream);
		squash_object_unref(this->squashStream);
		this->squashStream = nullptr;

		return * this;
	}
Example #6
0
static void
squash_brotli_stream_destroy (void* stream) {
  squash_stream_destroy (stream);
}
Example #7
0
static void
squash_copy_stream_destroy (void* stream) {
  squash_stream_destroy (stream);
}