mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-25 01:06:50 +00:00
use PyMemoryView_FromMemory (py 3.3+)
This commit is contained in:
parent
ef00f5d12d
commit
8e13d315bb
1 changed files with 2 additions and 15 deletions
|
@ -186,19 +186,6 @@ chunker_fill(Chunker *c)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
PyBuffer_FromMemory(void *data, Py_ssize_t len)
|
||||
{
|
||||
Py_buffer buffer;
|
||||
PyObject *mv;
|
||||
|
||||
PyBuffer_FillInfo(&buffer, NULL, data, len, 1, PyBUF_CONTIG_RO);
|
||||
mv = PyMemoryView_FromBuffer(&buffer);
|
||||
PyBuffer_Release(&buffer);
|
||||
return mv;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
chunker_process(Chunker *c)
|
||||
{
|
||||
|
@ -221,7 +208,7 @@ chunker_process(Chunker *c)
|
|||
c->done = 1;
|
||||
if(c->remaining) {
|
||||
c->bytes_yielded += c->remaining;
|
||||
return PyBuffer_FromMemory(c->data + c->position, c->remaining);
|
||||
return PyMemoryView_FromMemory(c->data + c->position, c->remaining, PyBUF_READ);
|
||||
}
|
||||
else {
|
||||
if(c->bytes_read == c->bytes_yielded)
|
||||
|
@ -253,5 +240,5 @@ chunker_process(Chunker *c)
|
|||
c->last = c->position;
|
||||
n = c->last - old_last;
|
||||
c->bytes_yielded += n;
|
||||
return PyBuffer_FromMemory(c->data + old_last, n);
|
||||
return PyMemoryView_FromMemory(c->data + old_last, n, PyBUF_READ);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue