Mercurial > hg > dmlib
comparison tools/lib64fmts.c @ 1748:9c4b3fecc510
Use the new DMGrowBuf functions in XX2 format buffer enlarging.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 11 Jun 2018 14:21:09 +0300 |
parents | 5e928618fdc8 |
children | feaf5cf07603 |
comparison
equal
deleted
inserted
replaced
1747:5e928618fdc8 | 1748:9c4b3fecc510 |
---|---|
529 DMGrowBuf tmp; | 529 DMGrowBuf tmp; |
530 | 530 |
531 // If there is only data for less than XX2_MIN_SIZE bytes, | 531 // If there is only data for less than XX2_MIN_SIZE bytes, |
532 // allocate a buffer of that size and copy data there. | 532 // allocate a buffer of that size and copy data there. |
533 // Otherwise allocate len bytes. | 533 // Otherwise allocate len bytes. |
534 size_t nlen = buf->len < XX2_MIN_SIZE ? XX2_MIN_SIZE : buf->len; | 534 if (dmGrowBufCopy(&tmp, buf, buf->len < XX2_MIN_SIZE ? XX2_MIN_SIZE - buf->len : 0) == NULL) |
535 Uint8 *mem = dmMalloc0(nlen); | |
536 if (mem == NULL) | |
537 return DMERR_MALLOC; | 535 return DMERR_MALLOC; |
538 | 536 |
539 memcpy(mem, buf->data, buf->len); | 537 tmp.len = tmp.size; |
540 res = dmC64DecodeGenericBMP(img, dmGrowBufCreateFrom(&tmp, mem, nlen), fmt); | 538 res = dmC64DecodeGenericBMP(img, &tmp, fmt); |
541 | 539 dmGrowBufFree(&tmp); |
542 dmFree(mem); | 540 |
543 return res; | 541 return res; |
544 } | 542 } |
545 | 543 |
546 | 544 |
547 #define FUNPAINT2_HEADER_SIZE (0x10) | 545 #define FUNPAINT2_HEADER_SIZE (0x10) |