Ticket #36: patch

File patch, 2.0 kB (added by grep, 1 year ago)
  • matchC.cc

    old new  
    842842 
    843843 
    844844static PyObject* sortArray(PyObject* self, PyObject* args) { 
    845    
    846   long* a; 
     845  PyObject* obj; 
     846  void* buffer; 
     847  Py_ssize_t buffer_len; 
    847848 
    848   unsigned long adr
     849  long* a
    849850  long l, r;          // it's important that these are signed! 
    850851 
    851   if (!PyArg_ParseTuple(args, "lii", &adr, &l, &r)) 
     852  if (!PyArg_ParseTuple(args, "Oii", &obj, &l, &r)) 
    852853    return NULL;  
     854  if (PyObject_AsWriteBuffer(obj, &buffer, &buffer_len)) 
     855    return NULL; 
    853856 
    854   a = (long*) adr; 
     857  a = (long*) buffer; 
    855858   
    856859  sortCArray(a, l, r); 
    857860  Py_INCREF(Py_None); 
     
    860863 
    861864 
    862865static PyObject* buildOutput(PyObject* self, PyObject* args) { 
     866  PyObject* obj; 
     867  void* buffer; 
     868  Py_ssize_t buffer_len; 
    863869   
    864870  long* a; 
    865   unsigned long adr, length; 
    866   if (!PyArg_ParseTuple(args, "li", &adr, &length)) 
     871  unsigned long length; 
     872  if (!PyArg_ParseTuple(args, "Oi", &obj, &length)) 
    867873    return NULL;  
     874  if (PyObject_AsWriteBuffer(obj, &buffer, &buffer_len)) 
     875    return NULL; 
    868876 
    869   a = (long*) adr; 
     877  a = (long*) buffer; 
    870878 
    871879  long *b = new long[length]; 
    872880  long bIndex = 0;