Commit 3b9baf46 authored by chris's avatar chris

extra byte in buffer no longer included in buf_size

parent 7f2a7ee9
/* /*
$Id: cStringIO.c,v 1.12 1997/01/24 19:38:28 chris Exp $ $Id: cStringIO.c,v 1.13 1997/01/24 19:45:20 chris Exp $
A simple fast partial StringIO replacement. A simple fast partial StringIO replacement.
...@@ -58,6 +58,9 @@ ...@@ -58,6 +58,9 @@
$Log: cStringIO.c,v $ $Log: cStringIO.c,v $
Revision 1.13 1997/01/24 19:45:20 chris
extra byte in buffer no longer included in buf_size
Revision 1.12 1997/01/24 19:38:28 chris Revision 1.12 1997/01/24 19:38:28 chris
*** empty log message *** *** empty log message ***
...@@ -292,10 +295,10 @@ O_cwrite(PyObject *self, char *c, int l) { ...@@ -292,10 +295,10 @@ O_cwrite(PyObject *self, char *c, int l) {
if(newl >= ((Oobject*)self)->buf_size) if(newl >= ((Oobject*)self)->buf_size)
{ {
((Oobject*)self)->buf_size*=2; ((Oobject*)self)->buf_size*=2;
if(((Oobject*)self)->buf_size <= newl) ((Oobject*)self)->buf_size=newl+1; if(((Oobject*)self)->buf_size <= newl) ((Oobject*)self)->buf_size=newl;
UNLESS(((Oobject*)self)->buf= UNLESS(((Oobject*)self)->buf=
(char*)realloc(((Oobject*)self)->buf, (char*)realloc(((Oobject*)self)->buf,
((Oobject*)self)->buf_size*sizeof(char))) (((Oobject*)self)->buf_size + 1) *sizeof(char)))
{ {
PyErr_SetString(PyExc_MemoryError,"out of memory"); PyErr_SetString(PyExc_MemoryError,"out of memory");
((Oobject*)self)->buf_size=((Oobject*)self)->pos=0; ((Oobject*)self)->buf_size=((Oobject*)self)->pos=0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment