use buffers as generic "read" buffers instead of char buffers

This is a typing kludge -- if your buffers have elements of size > 1 then we will be processing only a subset of the elements and treating each byte of the element as a separate entry.
Oh well.
This commit is contained in:
Zooko O'Whielacronx 2007-01-25 15:24:01 -07:00
parent dcfdee5f25
commit b4f30afe3d
1 changed files with 5 additions and 3 deletions

View File

@ -152,7 +152,7 @@ Encoder_encode(Encoder *self, PyObject *args) {
py_raise_fec_error("Precondition violation: %u'th item is required to offer the single-segment read character buffer protocol, but it does not.\n", i); py_raise_fec_error("Precondition violation: %u'th item is required to offer the single-segment read character buffer protocol, but it does not.\n", i);
goto err; goto err;
} }
if (PyObject_AsCharBuffer(fastinsharesitems[i], &(incshares[i]), &sz)) if (PyObject_AsReadBuffer(fastinsharesitems[i], &(incshares[i]), &sz))
goto err; goto err;
if (oldsz != 0 && oldsz != sz) { if (oldsz != 0 && oldsz != sz) {
py_raise_fec_error("Precondition violation: Input shares are required to be all the same length. oldsz: %Zu, sz: %Zu\n", oldsz, sz); py_raise_fec_error("Precondition violation: Input shares are required to be all the same length. oldsz: %Zu, sz: %Zu\n", oldsz, sz);
@ -385,9 +385,11 @@ Decoder_decode(Decoder *self, PyObject *args) {
if (csharenums[i] >= self->kk) if (csharenums[i] >= self->kk)
needtorecover+=1; needtorecover+=1;
if (!PyObject_CheckReadBuffer(fastsharesitems[i])) if (!PyObject_CheckReadBuffer(fastsharesitems[i])) {
py_raise_fec_error("Precondition violation: %u'th item is required to offer the single-segment read character buffer protocol, but it does not.\n", i);
goto err; goto err;
if (PyObject_AsCharBuffer(fastsharesitems[i], &(cshares[i]), &sz)) }
if (PyObject_AsReadBuffer(fastsharesitems[i], &(cshares[i]), &sz))
goto err; goto err;
if (oldsz != 0 && oldsz != sz) { if (oldsz != 0 && oldsz != sz) {
py_raise_fec_error("Precondition violation: Input shares are required to be all the same length. oldsz: %Zu, sz: %Zu\n", oldsz, sz); py_raise_fec_error("Precondition violation: Input shares are required to be all the same length. oldsz: %Zu, sz: %Zu\n", oldsz, sz);