chiark / gitweb /
mappings: Separate mapping methods into read-only and read-write.
[catacomb-python] / buffer.c
index ee0dd40de21d895231c75a91ebde407fd2cb6f42..7456a3dad85c6404c234435ba82add4396840daa 100644 (file)
--- a/buffer.c
+++ b/buffer.c
@@ -83,7 +83,7 @@ static int rbuf_pysegcount(PyObject *me, int *nn)
   { if (nn) *nn = BSZ(BUF_B(me)); return (1); }
 
 static int rbuf_pyreadbuf(PyObject *me, int seg, void **q)
   { if (nn) *nn = BSZ(BUF_B(me)); return (1); }
 
 static int rbuf_pyreadbuf(PyObject *me, int seg, void **q)
-  { assert(seg == 0); *q = BBASE(BUF_B(me)); return (BSZ(BUF_B(me))); }
+  { assert(seg == 0); *q = BCUR(BUF_B(me)); return (BLEFT(BUF_B(me))); }
 
 static PyObject *rbmeth_skip(PyObject *me, PyObject *arg)
 {
 
 static PyObject *rbmeth_skip(PyObject *me, PyObject *arg)
 {
@@ -236,6 +236,7 @@ static PyObject *rbget_offset(PyObject *me, void *hunoz)
 static int rbset_offset(PyObject *me, PyObject *x, void *hunoz)
 {
   size_t n;
 static int rbset_offset(PyObject *me, PyObject *x, void *hunoz)
 {
   size_t n;
+  if (!x) NIERR("__del__");
   if (!convszt(x, &n)) goto end;
   if (n > BSZ(BUF_B(me))) VALERR("out of range");
   BCUR(BUF_B(me)) = BBASE(BUF_B(me)) + n;
   if (!convszt(x, &n)) goto end;
   if (n > BSZ(BUF_B(me))) VALERR("out of range");
   BCUR(BUF_B(me)) = BBASE(BUF_B(me)) + n;
@@ -316,7 +317,7 @@ static PyTypeObject rbuf_pytype_skel = {
   0,                                   /* @tp_richcompare@ */
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_richcompare@ */
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
-  0,                                   /* @tp_iternexr@ */
+  0,                                   /* @tp_iternext@ */
   rbuf_pymethods,                      /* @tp_methods@ */
   0,                                   /* @tp_members@ */
   rbuf_pygetset,                       /* @tp_getset@ */
   rbuf_pymethods,                      /* @tp_methods@ */
   0,                                   /* @tp_members@ */
   rbuf_pygetset,                       /* @tp_getset@ */
@@ -549,7 +550,7 @@ static PyTypeObject wbuf_pytype_skel = {
   0,                                   /* @tp_richcompare@ */
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_richcompare@ */
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
-  0,                                   /* @tp_iternexr@ */
+  0,                                   /* @tp_iternext@ */
   wbuf_pymethods,                      /* @tp_methods@ */
   0,                                   /* @tp_members@ */
   wbuf_pygetset,                       /* @tp_getset@ */
   wbuf_pymethods,                      /* @tp_methods@ */
   0,                                   /* @tp_members@ */
   wbuf_pygetset,                       /* @tp_getset@ */