Debian Codegraph @

tests/integration/testzlib/testzlib.c

raw
1 #include <zlib.h>
2 #include <stdlib.h>
3 #include <Python.h>
4
5
6 static PyObject *
7 run(PyObject *self, PyObject *args)
8 {
9 int res;
10
11 (void)self;
12 (void)args;
13
14 #if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 24)
15 res = gzflags() != 0;
16 #elif defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 17)
17 /* blacklist ineffective on manylinux 2014 */
18 res = 0;
19 #elif defined(__GLIBC_PREREQ)
20 {
21 void* memory = zcalloc(NULL, 1U, 1U);
22 res = (memory != NULL);
23 zcfree(NULL, memory);
24 }
25 #else
26 res = 0;
27 #endif
28 return PyLong_FromLong(res);
29 }
30
31 /* Module initialization */
32 PyMODINIT_FUNC PyInit_testzlib(void)
33 {
34 static PyMethodDef module_methods[] = {
35 {"run", (PyCFunction)run, METH_NOARGS, "run."},
36 {NULL} /* Sentinel */
37 };
38 static struct PyModuleDef moduledef = {
39 PyModuleDef_HEAD_INIT,
40 "testzlib",
41 "testzlib module",
42 -1,
43 module_methods,
44 };
45 return PyModule_Create(&moduledef);
46 }