Lines 842-857
Link Here
|
842 |
|
842 |
|
843 |
|
843 |
|
844 |
static PyObject* sortArray(PyObject* self, PyObject* args) { |
844 |
static PyObject* sortArray(PyObject* self, PyObject* args) { |
845 |
|
845 |
PyObject* obj; |
846 |
long* a; |
846 |
void* buffer; |
|
|
847 |
Py_ssize_t buffer_len; |
847 |
|
848 |
|
848 |
unsigned long adr; |
849 |
long* a; |
849 |
long l, r; // it's important that these are signed! |
850 |
long l, r; // it's important that these are signed! |
850 |
|
851 |
|
851 |
if (!PyArg_ParseTuple(args, "lii", &adr, &l, &r)) |
852 |
if (!PyArg_ParseTuple(args, "Oii", &obj, &l, &r)) |
852 |
return NULL; |
853 |
return NULL; |
|
|
854 |
if (PyObject_AsWriteBuffer(obj, &buffer, &buffer_len)) |
855 |
return NULL; |
853 |
|
856 |
|
854 |
a = (long*) adr; |
857 |
a = (long*) buffer; |
855 |
|
858 |
|
856 |
sortCArray(a, l, r); |
859 |
sortCArray(a, l, r); |
857 |
Py_INCREF(Py_None); |
860 |
Py_INCREF(Py_None); |
Lines 860-872
Link Here
|
860 |
|
863 |
|
861 |
|
864 |
|
862 |
static PyObject* buildOutput(PyObject* self, PyObject* args) { |
865 |
static PyObject* buildOutput(PyObject* self, PyObject* args) { |
|
|
866 |
PyObject* obj; |
867 |
void* buffer; |
868 |
Py_ssize_t buffer_len; |
863 |
|
869 |
|
864 |
long* a; |
870 |
long* a; |
865 |
unsigned long adr, length; |
871 |
unsigned long length; |
866 |
if (!PyArg_ParseTuple(args, "li", &adr, &length)) |
872 |
if (!PyArg_ParseTuple(args, "Oi", &obj, &length)) |
867 |
return NULL; |
873 |
return NULL; |
|
|
874 |
if (PyObject_AsWriteBuffer(obj, &buffer, &buffer_len)) |
875 |
return NULL; |
868 |
|
876 |
|
869 |
a = (long*) adr; |
877 |
a = (long*) buffer; |
870 |
|
878 |
|
871 |
long *b = new long[length]; |
879 |
long *b = new long[length]; |
872 |
long bIndex = 0; |
880 |
long bIndex = 0; |