Mercurial > hg > dmlib
changeset 1831:ce1a734b016f
Change the logic of how DMGrowBuf works in "backwards" growing mode. Adjust
the code that uses this as well.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 22 Jun 2018 16:33:27 +0300 |
parents | 3d4bb20f6739 |
children | 843d3a593f05 |
files | src/dmgrowbuf.c tools/lib64gfx.c |
diffstat | 2 files changed, 9 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dmgrowbuf.c Fri Jun 22 16:17:06 2018 +0300 +++ b/src/dmgrowbuf.c Fri Jun 22 16:33:27 2018 +0300 @@ -256,13 +256,13 @@ { if (buf->literal) { - buf->offs -= len; - memcpy(buf->data + buf->offs, data, len); + for (size_t n = 0; n < len; n++) + buf->data[--buf->offs] = data[len - n]; } else { for (size_t n = 0; n < len; n++) - buf->data[buf->offs--] = data[n]; + buf->data[--buf->offs] = data[n]; } } else @@ -280,11 +280,10 @@ if (!dmGrowBufGrow(buf, sizeof(Uint8))) return FALSE; - buf->data[buf->offs] = value; if (buf->backwards) - buf->offs--; + buf->data[--buf->offs] = value; else - buf->offs++; + buf->data[buf->offs++] = value; return TRUE; } @@ -371,7 +370,7 @@ if (buf->backwards) { if (buf->offs > 0) - *value = buf->data[buf->offs--]; + *value = buf->data[--buf->offs]; else return FALSE; }
--- a/tools/lib64gfx.c Fri Jun 22 16:17:06 2018 +0300 +++ b/tools/lib64gfx.c Fri Jun 22 16:33:27 2018 +0300 @@ -385,14 +385,14 @@ { if (cfg->flags & DM_RLE_BACKWARDS_INPUT) { - src->offs = src->len - 1; + src->offs = src->len; src->backwards = TRUE; } if (cfg->flags & DM_RLE_BACKWARDS_OUTPUT) { dst->backwards = TRUE; - dst->offs = dst->size - 1; + dst->offs = dst->size; } } @@ -412,7 +412,7 @@ case DM_OUT_CROP_END: if (cfg->cropOutLen < dst->len) { - memmove(dst->data, dst->data + dst->len - cfg->cropOutLen + 1, cfg->cropOutLen - 1); + memmove(dst->data, dst->data + dst->len - cfg->cropOutLen, cfg->cropOutLen); dst->len = cfg->cropOutLen; } break;