comparison tools/lib64fmts.c @ 2329:0085ce04788b

Add return value (error code) to dmGenericRLEAnalyze() and pass it through where used.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 16 Sep 2019 10:24:49 +0300
parents 87533af8db64
children 6dc64deb6718
comparison
equal deleted inserted replaced
2328:b57517a01960 2329:0085ce04788b
402 cfg.type = DM_COMP_RLE_MARKER; 402 cfg.type = DM_COMP_RLE_MARKER;
403 cfg.flags = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_1; 403 cfg.flags = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_1;
404 cfg.rleMinCountB = 4; 404 cfg.rleMinCountB = 4;
405 cfg.rleMaxCountB = 255; 405 cfg.rleMaxCountB = 255;
406 406
407 dmGenericRLEAnalyze(&tmp, &cfg); 407 if ((res = dmGenericRLEAnalyze(&tmp, &cfg)) != DMERR_OK)
408 goto out;
408 409
409 // Add the header bits 410 // Add the header bits
410 if (!dmGrowBufPut(buf, (Uint8 *) magicID, strlen(magicID)) || 411 if (!dmGrowBufPut(buf, (Uint8 *) magicID, strlen(magicID)) ||
411 !dmGrowBufPutU8(buf, cfg.rleMarkerB)) 412 !dmGrowBufPutU8(buf, cfg.rleMarkerB))
412 { 413 {
528 cfg.rleMinCountB = 4; 529 cfg.rleMinCountB = 4;
529 cfg.rleMaxCountB = 255; 530 cfg.rleMaxCountB = 255;
530 cfg.rleMinCountW = 256; 531 cfg.rleMinCountW = 256;
531 cfg.rleMaxCountW = 1024; 532 cfg.rleMaxCountW = 1024;
532 533
533 dmGenericRLEAnalyze(&mem, &cfg); 534 if ((res = dmGenericRLEAnalyze(&mem, &cfg)) != DMERR_OK)
535 goto out;
534 536
535 // Add the header bits 537 // Add the header bits
536 if (!dmGrowBufPut(buf, (Uint8 *) fmtBDP5_MagicID, strlen(fmtBDP5_MagicID)) || 538 if (!dmGrowBufPut(buf, (Uint8 *) fmtBDP5_MagicID, strlen(fmtBDP5_MagicID)) ||
537 !dmGrowBufPutU8(buf, cfg.rleMarkerB) || 539 !dmGrowBufPutU8(buf, cfg.rleMarkerB) ||
538 !dmGrowBufPutU8(buf, cfg.rleMarkerW)) 540 !dmGrowBufPutU8(buf, cfg.rleMarkerW))
745 cfg.flags = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_1 | DM_RLE_ZERO_COUNT_MAX | 747 cfg.flags = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_1 | DM_RLE_ZERO_COUNT_MAX |
746 DM_RLE_BACKWARDS_INPUT | DM_RLE_BACKWARDS_OUTPUT; 748 DM_RLE_BACKWARDS_INPUT | DM_RLE_BACKWARDS_OUTPUT;
747 cfg.rleMinCountB = 4; 749 cfg.rleMinCountB = 4;
748 cfg.rleMaxCountB = 256; // this format allows 256 byte runs with ZERO_COUNT_MAX 750 cfg.rleMaxCountB = 256; // this format allows 256 byte runs with ZERO_COUNT_MAX
749 751
750 dmGenericRLEAnalyze(&tmp1, &cfg); 752 if ((res = dmGenericRLEAnalyze(&tmp1, &cfg)) != DMERR_OK)
753 goto out;
751 754
752 if ((res = dmEncodeGenericRLEAlloc(&tmp2, &tmp1, &cfg)) != DMERR_OK) 755 if ((res = dmEncodeGenericRLEAlloc(&tmp2, &tmp1, &cfg)) != DMERR_OK)
753 goto out; 756 goto out;
754 757
755 // Now, finally we must put in the header etc. 758 // Now, finally we must put in the header etc.
1247 cfg.type = DM_COMP_RLE_MARKER; 1250 cfg.type = DM_COMP_RLE_MARKER;
1248 cfg.flags = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_1; 1251 cfg.flags = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_1;
1249 cfg.rleMinCountB = 4; 1252 cfg.rleMinCountB = 4;
1250 cfg.rleMaxCountB = 255; 1253 cfg.rleMaxCountB = 255;
1251 1254
1252 dmGenericRLEAnalyze(&mem, &cfg); 1255 if ((res = dmGenericRLEAnalyze(&mem, &cfg)) != DMERR_OK)
1256 goto out;
1253 1257
1254 // Add the header bits 1258 // Add the header bits
1255 if (!dmGrowBufPut(buf, (Uint8 *) fmtFunPaint2_MagicID, strlen(fmtFunPaint2_MagicID)) || 1259 if (!dmGrowBufPut(buf, (Uint8 *) fmtFunPaint2_MagicID, strlen(fmtFunPaint2_MagicID)) ||
1256 !dmGrowBufPutU8(buf, 1) || // non-zero == packed variant 1260 !dmGrowBufPutU8(buf, 1) || // non-zero == packed variant
1257 !dmGrowBufPutU8(buf, cfg.rleMarkerB)) 1261 !dmGrowBufPutU8(buf, cfg.rleMarkerB))