Mercurial > hg > dmlib
diff tools/lib64gfx.c @ 1697:1036b0dcccb5
Refactor DMGrowBuf so that there can be buffers that grow "backwards".
This also removes some support functions like the buffer state push/pop.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 05 Jun 2018 12:55:17 +0300 |
parents | 09adf5328510 |
children | a0986cfd6f9d |
line wrap: on
line diff
--- a/tools/lib64gfx.c Tue Jun 05 11:36:55 2018 +0300 +++ b/tools/lib64gfx.c Tue Jun 05 12:55:17 2018 +0300 @@ -905,7 +905,12 @@ goto err; } - dmGrowBufPush(buf); + if (buf->backwards) + { + dmError(DMERR_INVALID_DATA, + "Buffer specified for dmC64EncodeGenericBMP() is in backwards mode, which is not supported.\n"); + goto err; + } // Perform encoding for (int i = 0; i < D64_MAX_ENCDEC_OPS; i++) @@ -935,7 +940,7 @@ } // Do we need to reallocate some more space? - chksize = op->offs + size; + chksize = buf->offs + op->offs + size; if (!dmGrowBufCheckGrow(buf, chksize)) { res = dmError(DMERR_MALLOC, @@ -948,8 +953,7 @@ buf->len = chksize; // Perform operation - Uint8 *dst; - dst = buf->data + op->offs; + Uint8 *dst = buf->data + buf->offs + op->offs; switch (op->type) { case DO_COPY: @@ -1060,8 +1064,6 @@ } } - dmGrowBufPop(buf); - res = DMERR_OK; err: