comparison output.c @ 39:337110e7240a

Pass the size to free; it makes debug checking easier.
author David A. Holland
date Sat, 30 Mar 2013 21:17:47 -0400
parents 76c114899f63
children 4cc1c575951f
comparison
equal deleted inserted replaced
38:b156910b59b2 39:337110e7240a
147 } 147 }
148 148
149 void 149 void
150 output(const struct place *p, const char *buf, size_t len) 150 output(const struct place *p, const char *buf, size_t len)
151 { 151 {
152 size_t oldmax;
153
152 if (linebufpos + len > linebufmax) { 154 if (linebufpos + len > linebufmax) {
155 oldmax = linebufmax;
153 if (linebufmax == 0) { 156 if (linebufmax == 0) {
154 linebufmax = 64; 157 linebufmax = 64;
155 } 158 }
156 while (linebufpos + len > linebufmax) { 159 while (linebufpos + len > linebufmax) {
157 linebufmax *= 2; 160 linebufmax *= 2;
158 } 161 }
159 linebuf = dorealloc(linebuf, linebufmax); 162 linebuf = dorealloc(linebuf, oldmax, linebufmax);
160 } 163 }
161 if (linebufpos == 0) { 164 if (linebufpos == 0) {
162 linebufplace = *p; 165 linebufplace = *p;
163 } 166 }
164 memcpy(linebuf + linebufpos, buf, len); 167 memcpy(linebuf + linebufpos, buf, len);