comparison src/dmzlib.c @ 1167:848a88ce7a57

Use dmMemset().
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 05 Mar 2015 07:37:35 +0200
parents d0898867ec4c
children 749f8f808531
comparison
equal deleted inserted replaced
1166:f29fa5b6b748 1167:848a88ce7a57
90 static int dmZLibBuildHuffmanTables(DMZHuffmanContext * ctx, const Uint8 * sizelist, const int num) 90 static int dmZLibBuildHuffmanTables(DMZHuffmanContext * ctx, const Uint8 * sizelist, const int num)
91 { 91 {
92 int i, k = 0; 92 int i, k = 0;
93 int code, nextCode[16], sizes[17]; 93 int code, nextCode[16], sizes[17];
94 94
95 memset(sizes, 0, sizeof(sizes)); 95 dmMemset(sizes, 0, sizeof(sizes));
96 memset(ctx->fast, 0, sizeof(ctx->fast)); 96 dmMemset(ctx->fast, 0, sizeof(ctx->fast));
97 97
98 for (i = 0; i < num; i++) 98 for (i = 0; i < num; i++)
99 sizes[sizelist[i]]++; 99 sizes[sizelist[i]]++;
100 100
101 sizes[0] = 0; 101 sizes[0] = 0;
405 hlit, hdist); 405 hlit, hdist);
406 } 406 }
407 407
408 // Get lengths table (uninitialized entries should be set to 0) 408 // Get lengths table (uninitialized entries should be set to 0)
409 codeLengths[256] = 0; 409 codeLengths[256] = 0;
410 memset(codeLengthSizes, 0, sizeof(codeLengthSizes)); 410 dmMemset(codeLengthSizes, 0, sizeof(codeLengthSizes));
411 for (i = 0; i < hclen; i++) 411 for (i = 0; i < hclen; i++)
412 { 412 {
413 int s = dmZReceive(ctx, 3); 413 int s = dmZReceive(ctx, 3);
414 codeLengthSizes[dm_zlib_length_dezigzag[i]] = (Uint8) s; 414 codeLengthSizes[dm_zlib_length_dezigzag[i]] = (Uint8) s;
415 } 415 }
440 if (n == 0) 440 if (n == 0)
441 { 441 {
442 return dmErrorDBG(DMERR_INVALID_DATA, 442 return dmErrorDBG(DMERR_INVALID_DATA,
443 "Invalid bit length repeat.\n"); 443 "Invalid bit length repeat.\n");
444 } 444 }
445 memset(codeLengths + n, codeLengths[n - 1], bv); 445 dmMemset(codeLengths + n, codeLengths[n - 1], bv);
446 n += bv; 446 n += bv;
447 } 447 }
448 else 448 else
449 if (c == 17) 449 if (c == 17)
450 { 450 {
451 int bv = dmZReceive(ctx, 3) + 3; 451 int bv = dmZReceive(ctx, 3) + 3;
452 memset(codeLengths + n, 0, bv); 452 dmMemset(codeLengths + n, 0, bv);
453 n += bv; 453 n += bv;
454 } 454 }
455 else 455 else
456 { 456 {
457 int bv = dmZReceive(ctx, 7) + 11; 457 int bv = dmZReceive(ctx, 7) + 11;
458 memset(codeLengths + n, 0, bv); 458 dmMemset(codeLengths + n, 0, bv);
459 n += bv; 459 n += bv;
460 } 460 }
461 } 461 }
462 462
463 if (codeLengths[256] == 0) 463 if (codeLengths[256] == 0)
552 int dmZLibInitInflate(DMZLibContext *ctx) 552 int dmZLibInitInflate(DMZLibContext *ctx)
553 { 553 {
554 if (ctx == NULL) 554 if (ctx == NULL)
555 return DMERR_NULLPTR; 555 return DMERR_NULLPTR;
556 556
557 memset(ctx, 0, sizeof(DMZLibContext)); 557 dmMemset(ctx, 0, sizeof(DMZLibContext));
558 return DMERR_OK; 558 return DMERR_OK;
559 } 559 }
560 560
561 561
562 void dmZLibCloseInflate(DMZLibContext *ctx) 562 void dmZLibCloseInflate(DMZLibContext *ctx)
563 { 563 {
564 if (ctx != NULL) 564 if (ctx != NULL)
565 { 565 {
566 memset(ctx, 0, sizeof(DMZLibContext)); 566 dmMemset(ctx, 0, sizeof(DMZLibContext));
567 } 567 }
568 } 568 }
569 569
570 570
571 int dmZLibInflate(DMZLibContext * ctx) 571 int dmZLibInflate(DMZLibContext * ctx)