--- kombilo05/matchC.cc~ 2004-07-02 21:03:56.000000000 +0300 +++ kombilo05/matchC.cc 2007-06-20 08:44:22.000000000 +0300 @@ -842,16 +842,19 @@ static PyObject* sortArray(PyObject* self, PyObject* args) { - - long* a; + PyObject* obj; + void* buffer; + Py_ssize_t buffer_len; - unsigned long adr; + long* a; long l, r; // it's important that these are signed! - if (!PyArg_ParseTuple(args, "lii", &adr, &l, &r)) + if (!PyArg_ParseTuple(args, "Oii", &obj, &l, &r)) return NULL; + if (PyObject_AsWriteBuffer(obj, &buffer, &buffer_len)) + return NULL; - a = (long*) adr; + a = (long*) buffer; sortCArray(a, l, r); Py_INCREF(Py_None); @@ -860,13 +863,18 @@ static PyObject* buildOutput(PyObject* self, PyObject* args) { + PyObject* obj; + void* buffer; + Py_ssize_t buffer_len; long* a; - unsigned long adr, length; - if (!PyArg_ParseTuple(args, "li", &adr, &length)) + unsigned long length; + if (!PyArg_ParseTuple(args, "Oi", &obj, &length)) return NULL; + if (PyObject_AsWriteBuffer(obj, &buffer, &buffer_len)) + return NULL; - a = (long*) adr; + a = (long*) buffer; long *b = new long[length]; long bIndex = 0; --- kombilo05/kombilo.py 2004-07-02 21:03:56.000000000 +0300 +++ kombilo05/kombilo.py 2007-06-20 08:43:50.000000000 +0300 @@ -2131,7 +2131,7 @@ def sort(self): if CimportSucceeded: - matchC.sortArray(self.data.buffer_info()[0], 0, self.dataIndex/2-1) + matchC.sortArray(self.data, 0, self.dataIndex/2-1) else: l = 0 r = self.dataIndex/2 - 1 @@ -2179,7 +2179,7 @@ self.sort() if CimportSucceeded: - hashT, hash = matchC.buildOutput(self.data.buffer_info()[0], self.dataIndex) + hashT, hash = matchC.buildOutput(self.data, self.dataIndex) file = open(os.path.join(path[0], 'hashT' + path[1] + '.db'), 'wb') file.write(hashT) file.close()