Mercurial > hg > dmlib
comparison src/dmzlib.c @ 965:df8d2ad98f7d
Rename a function argument.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 27 Feb 2015 05:22:20 +0200 |
parents | 76ac0d5c89b3 |
children | b522067e2beb |
comparison
equal
deleted
inserted
replaced
964:76ac0d5c89b3 | 965:df8d2ad98f7d |
---|---|
418 | 418 |
419 return DMERR_OK; | 419 return DMERR_OK; |
420 } | 420 } |
421 | 421 |
422 | 422 |
423 static int dmZLibParseUncompresedBlock(DMZLibContext * a) | 423 static int dmZLibParseUncompresedBlock(DMZLibContext * ctx) |
424 { | 424 { |
425 Uint8 header[4]; | 425 Uint8 header[4]; |
426 int len, nlen, k; | 426 int len, nlen, k; |
427 | 427 |
428 if (a->numBits & 7) | 428 if (ctx->numBits & 7) |
429 dmZReceive(a, a->numBits & 7); // discard | 429 dmZReceive(ctx, ctx->numBits & 7); // discard |
430 | 430 |
431 // drain the bit-packed data into header | 431 // drain the bit-packed data into header |
432 k = 0; | 432 k = 0; |
433 while (a->numBits > 0) | 433 while (ctx->numBits > 0) |
434 { | 434 { |
435 header[k++] = (Uint8) (a->codeBuffer & 255); // suppress MSVC run-time check | 435 header[k++] = (Uint8) (ctx->codeBuffer & 255); // suppress MSVC run-time check |
436 a->codeBuffer >>= 8; | 436 ctx->codeBuffer >>= 8; |
437 a->numBits -= 8; | 437 ctx->numBits -= 8; |
438 } | 438 } |
439 DMSTBI_ASSERT(a->numBits == 0); | 439 DMSTBI_ASSERT(ctx->numBits == 0); |
440 | 440 |
441 // now fill header the normal way | 441 // now fill header the normal way |
442 while (k < 4) | 442 while (k < 4) |
443 header[k++] = dmZGet8(a); | 443 header[k++] = dmZGet8(ctx); |
444 | 444 |
445 len = (header[1] << 8) | header[0]; | 445 len = (header[1] << 8) | header[0]; |
446 nlen = (header[3] << 8) | header[2]; | 446 nlen = (header[3] << 8) | header[2]; |
447 | 447 |
448 if (nlen != (len ^ 0xffff)) | 448 if (nlen != (len ^ 0xffff)) |
449 { | 449 { |
450 return dmError(DMERR_DATA_ERROR, | 450 return dmError(DMERR_DATA_ERROR, |
451 "Compressed data corrupt.\n"); | 451 "Compressed data corrupt.\n"); |
452 } | 452 } |
453 | 453 |
454 if (a->zbuffer + len > a->zbufferEnd) | 454 if (ctx->zbuffer + len > ctx->zbufferEnd) |
455 { | 455 { |
456 return dmError(DMERR_BOUNDS, | 456 return dmError(DMERR_BOUNDS, |
457 "Read past buffer, probably corrupt compressed data.\n"); | 457 "Read past buffer, probably corrupt compressed data.\n"); |
458 } | 458 } |
459 | 459 |
460 if (a->zout + len > a->zoutEnd && !stbi__zexpand(a, a->zout, len)) | 460 if (ctx->zout + len > ctx->zoutEnd && !stbi__zexpand(ctx, ctx->zout, len)) |
461 { | 461 { |
462 return dmError(DMERR_DATA_ERROR, | 462 return dmError(DMERR_DATA_ERROR, |
463 "XXXX TODO"); | 463 "XXXX TODO"); |
464 } | 464 } |
465 | 465 |
466 memcpy(a->zout, a->zbuffer, len); | 466 memcpy(ctx->zout, ctx->zbuffer, len); |
467 a->zbuffer += len; | 467 ctx->zbuffer += len; |
468 a->zout += len; | 468 ctx->zout += len; |
469 | 469 |
470 return DMERR_OK; | 470 return DMERR_OK; |
471 } | 471 } |
472 | 472 |
473 | 473 |