comparison tools/lib64gfx.c @ 1518:24b8b452925e

Improve error handling of RLE encoder.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 11 May 2018 23:11:16 +0300
parents 181163a6dd24
children 19b5013ff190
comparison
equal deleted inserted replaced
1517:1be17c662b8e 1518:24b8b452925e
375 Uint8 data = *src++; 375 Uint8 data = *src++;
376 376
377 if (data != prev || count >= cfg->rleMaxCount) 377 if (data != prev || count >= cfg->rleMaxCount)
378 { 378 {
379 if (!dmEncodeGenericRLESequence(dst, prev, count, cfg)) 379 if (!dmEncodeGenericRLESequence(dst, prev, count, cfg))
380 {
381 res = dmError(DMERR_MALLOC,
382 "Could reallocate memory for RLE encoding buffer.\n");
383 goto err; 380 goto err;
384 }
385 381
386 count = 1; 382 count = 1;
387 } 383 }
388 else 384 else
389 count++; 385 count++;
390 386
391 prev = data; 387 prev = data;
392 } 388 }
393 389
394 res = DMERR_OK; 390 if (!dmEncodeGenericRLESequence(dst, prev, count, cfg))
391 goto err;
392
393 return DMERR_OK;
395 394
396 err: 395 err:
397 return res; 396 return dmError(DMERR_MALLOC,
397 "Could reallocate memory for RLE encoding buffer.\n");
398 } 398 }
399 399
400 400
401 int dmEncodeGenericRLEAlloc(DMGrowBuf *dst, const Uint8 *src, const Uint8 *srcEnd, const DMCompParams *cfg) 401 int dmEncodeGenericRLEAlloc(DMGrowBuf *dst, const Uint8 *src, const Uint8 *srcEnd, const DMCompParams *cfg)
402 { 402 {