Skip to content

Commit 8034d4e

Browse files
committed
Move crc32_combine closer to crc32
1 parent 95da6ff commit 8034d4e

File tree

1 file changed

+34
-33
lines changed

1 file changed

+34
-33
lines changed

src/isal/isal_zlibmodule.c

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,40 @@ isal_zlib_crc32(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
254254
PyBuffer_Release(&data);
255255
return return_value;
256256
}
257+
258+
PyDoc_STRVAR(isal_zlib_crc32_combine__doc__,
259+
"crc32_combine($module, crc1, crc2, crc2_length /)\n"
260+
"--\n"
261+
"\n"
262+
"Combine crc1 and crc2 into a new crc that is accurate for the combined data \n"
263+
"blocks that crc1 and crc2 where calculated from.\n"
264+
"\n"
265+
" crc1\n"
266+
" the first crc32 checksum\n"
267+
" crc2\n"
268+
" the second crc32 checksum\n"
269+
" crc2_length\n"
270+
" the lenght of the data block crc2 was calculated from\n"
271+
);
272+
273+
274+
#define ISAL_ZLIB_CRC32_COMBINE_METHODDEF \
275+
{"crc32_combine", (PyCFunction)(void(*)(void))isal_zlib_crc32_combine, \
276+
METH_VARARGS, isal_zlib_crc32_combine__doc__}
277+
278+
static PyObject *
279+
isal_zlib_crc32_combine(PyObject *module, PyObject *args) {
280+
uint32_t crc1 = 0;
281+
uint32_t crc2 = 0;
282+
Py_ssize_t crc2_length = 0;
283+
static char *format = "IIn:crc32combine";
284+
if (PyArg_ParseTuple(args, format, &crc1, &crc2, &crc2_length) < 0) {
285+
return NULL;
286+
}
287+
return PyLong_FromUnsignedLong(
288+
crc32_comb(crc1, crc2, crc2_length) & 0xFFFFFFFF);
289+
}
290+
257291
PyDoc_STRVAR(zlib_compress__doc__,
258292
"compress($module, data, /, level=ISAL_DEFAULT_COMPRESSION, wbits=MAX_WBITS)\n"
259293
"--\n"
@@ -1188,39 +1222,6 @@ isal_zlib_Decompress_flush(decompobject *self, PyObject *const *args, Py_ssize_t
11881222
return isal_zlib_Decompress_flush_impl(self, length);
11891223
}
11901224

1191-
PyDoc_STRVAR(isal_zlib_crc32_combine__doc__,
1192-
"crc32_combine($module, crc1, crc2, crc2_length /)\n"
1193-
"--\n"
1194-
"\n"
1195-
"Combine crc1 and crc2 into a new crc that is accurate for the combined data \n"
1196-
"blocks that crc1 and crc2 where calculated from.\n"
1197-
"\n"
1198-
" crc1\n"
1199-
" the first crc32 checksum\n"
1200-
" crc2\n"
1201-
" the second crc32 checksum\n"
1202-
" crc2_length\n"
1203-
" the lenght of the data block crc2 was calculated from\n"
1204-
);
1205-
1206-
1207-
#define ISAL_ZLIB_CRC32_COMBINE_METHODDEF \
1208-
{"crc32_combine", (PyCFunction)(void(*)(void))isal_zlib_crc32_combine, \
1209-
METH_VARARGS, isal_zlib_crc32_combine__doc__}
1210-
1211-
static PyObject *
1212-
isal_zlib_crc32_combine(PyObject *module, PyObject *args) {
1213-
uint32_t crc1 = 0;
1214-
uint32_t crc2 = 0;
1215-
Py_ssize_t crc2_length = 0;
1216-
static char *format = "IIn:crc32combine";
1217-
if (PyArg_ParseTuple(args, format, &crc1, &crc2, &crc2_length) < 0) {
1218-
return NULL;
1219-
}
1220-
return PyLong_FromUnsignedLong(
1221-
crc32_comb(crc1, crc2, crc2_length) & 0xFFFFFFFF);
1222-
}
1223-
12241225

12251226
static PyMethodDef comp_methods[] = {
12261227
ISAL_ZLIB_COMPRESS_COMPRESS_METHODDEF,

0 commit comments

Comments
 (0)