##// END OF EJS Templates
cext: use modern buffer protocol in mpatch_flist()...
Gregory Szorc -
r40028:ec3c06a1 default
parent child Browse files
Show More
@@ -50,21 +50,22 b' static void setpyerr(int r)'
50
50
51 struct mpatch_flist *cpygetitem(void *bins, ssize_t pos)
51 struct mpatch_flist *cpygetitem(void *bins, ssize_t pos)
52 {
52 {
53 const char *buffer;
53 Py_buffer buffer;
54 struct mpatch_flist *res;
54 struct mpatch_flist *res = NULL;
55 ssize_t blen;
56 int r;
55 int r;
57
56
58 PyObject *tmp = PyList_GetItem((PyObject *)bins, pos);
57 PyObject *tmp = PyList_GetItem((PyObject *)bins, pos);
59 if (!tmp)
58 if (!tmp)
60 return NULL;
59 return NULL;
61 if (PyObject_AsCharBuffer(tmp, &buffer, (Py_ssize_t *)&blen))
60 if (PyObject_GetBuffer(tmp, &buffer, PyBUF_CONTIG_RO))
62 return NULL;
61 return NULL;
63 if ((r = mpatch_decode(buffer, blen, &res)) < 0) {
62 if ((r = mpatch_decode(buffer.buf, buffer.len, &res)) < 0) {
64 if (!PyErr_Occurred())
63 if (!PyErr_Occurred())
65 setpyerr(r);
64 setpyerr(r);
66 return NULL;
65 res = NULL;
67 }
66 }
67
68 PyBuffer_Release(&buffer);
68 return res;
69 return res;
69 }
70 }
70
71
General Comments 0
You need to be logged in to leave comments. Login now