Mercurial > hg > dmlib
comparison tools/lib64gfx.c @ 1364:0d61895e1763
Cleanup.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 22 Sep 2017 23:00:32 +0300 |
parents | 7bc67ba68904 |
children | 60d7240e1a63 |
comparison
equal
deleted
inserted
replaced
1363:3af0057f377d | 1364:0d61895e1763 |
---|---|
906 // Perform encoding | 906 // Perform encoding |
907 for (i = 0; i < fmt->nencdecOps; i++) | 907 for (i = 0; i < fmt->nencdecOps; i++) |
908 { | 908 { |
909 const DMC64EncDecOp *op = &fmt->encdecOps[i]; | 909 const DMC64EncDecOp *op = &fmt->encdecOps[i]; |
910 Uint8 *dst = 2 + buf + op->offs; | 910 Uint8 *dst = 2 + buf + op->offs; |
911 size_t size; | 911 size_t size, chksize; |
912 | 912 |
913 // Check operation validity | 913 // Check operation validity |
914 if ((res = dmC64SanityCheckEncDecOp(i, op)) != DMERR_OK) | 914 if ((res = dmC64SanityCheckEncDecOp(i, op)) != DMERR_OK) |
915 goto error; | 915 goto error; |
916 | 916 |
923 i, op->type, op->offs, op->offs, op->bank, size, size, op->size, op->size); | 923 i, op->type, op->offs, op->offs, op->bank, size, size, op->size, op->size); |
924 goto error; | 924 goto error; |
925 } | 925 } |
926 | 926 |
927 // Do we need to reallocate some more space? | 927 // Do we need to reallocate some more space? |
928 if (2 + op->offs + size > allocated) | 928 chksize = op->offs + size + 2; |
929 { | 929 if (chksize > allocated) |
930 size_t diff = allocated - (op->offs + size + 2), | 930 { |
931 size_t diff = allocated - chksize, | |
931 grow = (diff / (BUF_SIZE_GROW - 1)) * BUF_SIZE_GROW; | 932 grow = (diff / (BUF_SIZE_GROW - 1)) * BUF_SIZE_GROW; |
932 | 933 |
933 allocated += grow; | 934 allocated += grow; |
934 | 935 |
935 if ((buf = dmRealloc(buf, allocated)) == NULL) | 936 if ((buf = dmRealloc(buf, allocated)) == NULL) |
939 allocated); | 940 allocated); |
940 goto error; | 941 goto error; |
941 } | 942 } |
942 } | 943 } |
943 | 944 |
944 if (fmt->size == 0 && op->offs + size + 2 > *plen) | 945 if (fmt->size == 0 && chksize > *plen) |
945 *plen = op->offs + size + 2; | 946 *plen = chksize; |
946 | 947 |
947 // Perform operation | 948 // Perform operation |
948 switch (op->type) | 949 switch (op->type) |
949 { | 950 { |
950 case DT_COLOR_RAM: memcpy(dst, img->color[op->bank], size); break; | 951 case DT_COLOR_RAM: memcpy(dst, img->color[op->bank], size); break; |