comparison src/dmgrowbuf.c @ 1784:a29d38862037

Improve DMGrowBuf debugging slightly.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 13 Jun 2018 01:37:36 +0300
parents 22b6fa1a2ee4
children 86d10d5d4915
comparison
equal deleted inserted replaced
1783:1ce808599129 1784:a29d38862037
169 return FALSE; 169 return FALSE;
170 170
171 // For buffers growing backwards, we must move the 171 // For buffers growing backwards, we must move the
172 // current data to the end of the buffer .. 172 // current data to the end of the buffer ..
173 size_t clrsize = nsize - buf->size; 173 size_t clrsize = nsize - buf->size;
174 DM_DBG(" clrsize=%" DM_PRIu_SIZE_T "\n", clrsize);
174 if (buf->backwards) 175 if (buf->backwards)
175 { 176 {
176 memmove(buf->data + clrsize, buf->data, clrsize); 177 memmove(buf->data + clrsize, buf->data, clrsize);
177 buf->offs += clrsize; 178 buf->offs += clrsize;
178 } 179 }
206 207
207 if (buf->data == NULL || 208 if (buf->data == NULL ||
208 (buf->backwards && amount >= buf->offs) || 209 (buf->backwards && amount >= buf->offs) ||
209 (!buf->backwards && buf->offs + amount >= buf->size)) 210 (!buf->backwards && buf->offs + amount >= buf->size))
210 { 211 {
212 DM_DBG("dmGrowBufGrow(%p, amount=%" DM_PRIu_SIZE_T "): grow=%" DM_PRIu_SIZE_T "\n",
213 buf, amount, grow);
214
211 if (!dmGrowBufRealloc(buf, buf->size + grow, TRUE)) 215 if (!dmGrowBufRealloc(buf, buf->size + grow, TRUE))
212 return FALSE; 216 return FALSE;
213 } 217 }
214 218
215 buf->len += amount; 219 buf->len += amount;