equal
deleted
inserted
replaced
48 } |
48 } |
49 } |
49 } |
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 |
71 static PyObject *patches(PyObject *self, PyObject *args) |
72 static PyObject *patches(PyObject *self, PyObject *args) |
72 { |
73 { |