comparison contrib/python-zstandard/c-ext/compressionwriter.c @ 40121:73fef626dae3

zstandard: vendor python-zstandard 0.10.1 This was just released. The upstream source distribution from PyPI was extracted. Unwanted files were removed. The clang-format ignore list was updated to reflect the new source of files. setup.py was updated to pass a new argument to python-zstandard's function for returning an Extension instance. Upstream had to change to use relative paths because Python 3.7's packaging doesn't seem to like absolute paths when defining sources, includes, etc. The default relative path calculation is relative to setup_zstd.py which is different from the directory of Mercurial's setup.py. The project contains a vendored copy of zstandard 1.3.6. The old version was 1.3.4. The API should be backwards compatible and nothing in core should need adjusted. However, there is a new "chunker" API that we may find useful in places where we want to emit compressed chunks of a fixed size. There are a pair of bug fixes in 0.10.0 with regards to compressobj() and decompressobj() when block flushing is used. I actually found these bugs when introducing these APIs in Mercurial! But existing Mercurial code is not affected because we don't perform block flushing. # no-check-commit because 3rd party code has different style guidelines Differential Revision: https://phab.mercurial-scm.org/D4911
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 08 Oct 2018 16:27:40 -0700
parents b1fb341d8a61
children 675775c33ab6
comparison
equal deleted inserted replaced
40120:89742f1fa6cb 40121:73fef626dae3
220 PyMem_Free(output.dst); 220 PyMem_Free(output.dst);
221 PyErr_Format(ZstdError, "zstd compress error: %s", ZSTD_getErrorName(zresult)); 221 PyErr_Format(ZstdError, "zstd compress error: %s", ZSTD_getErrorName(zresult));
222 return NULL; 222 return NULL;
223 } 223 }
224 224
225 if (!output.pos) {
226 break;
227 }
228
229 /* Copy data from output buffer to writer. */ 225 /* Copy data from output buffer to writer. */
230 if (output.pos) { 226 if (output.pos) {
231 #if PY_MAJOR_VERSION >= 3 227 #if PY_MAJOR_VERSION >= 3
232 res = PyObject_CallMethod(self->writer, "write", "y#", 228 res = PyObject_CallMethod(self->writer, "write", "y#",
233 #else 229 #else
236 output.dst, output.pos); 232 output.dst, output.pos);
237 Py_XDECREF(res); 233 Py_XDECREF(res);
238 totalWrite += output.pos; 234 totalWrite += output.pos;
239 self->bytesCompressed += output.pos; 235 self->bytesCompressed += output.pos;
240 } 236 }
237
241 output.pos = 0; 238 output.pos = 0;
239
240 if (!zresult) {
241 break;
242 }
242 } 243 }
243 244
244 PyMem_Free(output.dst); 245 PyMem_Free(output.dst);
245 246
246 return PyLong_FromSsize_t(totalWrite); 247 return PyLong_FromSsize_t(totalWrite);