contrib/python-zstandard/c-ext/compressoriterator.c
changeset 42070 675775c33ab6
parent 37495 b1fb341d8a61
child 46374 e92ca942ddca
equal deleted inserted replaced
42069:668eff08387f 42070:675775c33ab6
    55 feedcompressor:
    55 feedcompressor:
    56 
    56 
    57 	/* If we have data left in the input, consume it. */
    57 	/* If we have data left in the input, consume it. */
    58 	if (self->input.pos < self->input.size) {
    58 	if (self->input.pos < self->input.size) {
    59 		Py_BEGIN_ALLOW_THREADS
    59 		Py_BEGIN_ALLOW_THREADS
    60 		zresult = ZSTD_compress_generic(self->compressor->cctx, &self->output,
    60 		zresult = ZSTD_compressStream2(self->compressor->cctx, &self->output,
    61 			&self->input, ZSTD_e_continue);
    61 			&self->input, ZSTD_e_continue);
    62 		Py_END_ALLOW_THREADS
    62 		Py_END_ALLOW_THREADS
    63 
    63 
    64 		/* Release the Python object holding the input buffer. */
    64 		/* Release the Python object holding the input buffer. */
    65 		if (self->input.pos == self->input.size) {
    65 		if (self->input.pos == self->input.size) {
   125 	if (0 == readSize) {
   125 	if (0 == readSize) {
   126 		self->input.src = NULL;
   126 		self->input.src = NULL;
   127 		self->input.size = 0;
   127 		self->input.size = 0;
   128 		self->input.pos = 0;
   128 		self->input.pos = 0;
   129 
   129 
   130 		zresult = ZSTD_compress_generic(self->compressor->cctx, &self->output,
   130 		zresult = ZSTD_compressStream2(self->compressor->cctx, &self->output,
   131 			&self->input, ZSTD_e_end);
   131 			&self->input, ZSTD_e_end);
   132 		if (ZSTD_isError(zresult)) {
   132 		if (ZSTD_isError(zresult)) {
   133 			PyErr_Format(ZstdError, "error ending compression stream: %s",
   133 			PyErr_Format(ZstdError, "error ending compression stream: %s",
   134 				ZSTD_getErrorName(zresult));
   134 				ZSTD_getErrorName(zresult));
   135 			return NULL;
   135 			return NULL;
   150 	self->input.src = readBuffer;
   150 	self->input.src = readBuffer;
   151 	self->input.size = readSize;
   151 	self->input.size = readSize;
   152 	self->input.pos = 0;
   152 	self->input.pos = 0;
   153 
   153 
   154 	Py_BEGIN_ALLOW_THREADS
   154 	Py_BEGIN_ALLOW_THREADS
   155 	zresult = ZSTD_compress_generic(self->compressor->cctx, &self->output,
   155 	zresult = ZSTD_compressStream2(self->compressor->cctx, &self->output,
   156 		&self->input, ZSTD_e_continue);
   156 		&self->input, ZSTD_e_continue);
   157 	Py_END_ALLOW_THREADS
   157 	Py_END_ALLOW_THREADS
   158 
   158 
   159 	/* The input buffer currently points to memory managed by Python
   159 	/* The input buffer currently points to memory managed by Python
   160 	(readBuffer). This object was allocated by this function. If it wasn't
   160 	(readBuffer). This object was allocated by this function. If it wasn't