Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.0 KiB

  1. /*
  2. * fstdebug.c
  3. *
  4. * Debugging stubs for fast encoder
  5. */
  6. #include <string.h>
  7. #include <stdio.h>
  8. #include <crtdbg.h>
  9. #include "deflate.h"
  10. #ifdef FULL_DEBUG
  11. void FastEncoderVerifyHashes(t_encoder_context *context, long bufpos)
  12. {
  13. int i;
  14. const t_search_node *lookup = context->fast_encoder->lookup;
  15. const t_search_node *prev = context->fast_encoder->prev;
  16. const BYTE *window = context->fast_encoder->window;
  17. for (i = 0; i < FAST_ENCODER_HASH_TABLE_SIZE; i++)
  18. {
  19. t_search_node where = lookup[i];
  20. t_search_node next_where;
  21. while (where != 0 && bufpos - where < FAST_ENCODER_WINDOW_SIZE)
  22. {
  23. int hash = FAST_ENCODER_RECALCULATE_HASH(where);
  24. _ASSERT(hash == i);
  25. next_where = prev[where & FAST_ENCODER_WINDOW_MASK];
  26. if (bufpos - next_where >= FAST_ENCODER_WINDOW_SIZE)
  27. break;
  28. _ASSERT(next_where < where);
  29. where = next_where;
  30. }
  31. }
  32. }
  33. void FastEncoderVerifyHashChain(t_encoder_context *context, long bufpos, int chain_number)
  34. {
  35. const t_search_node *lookup = context->fast_encoder->lookup;
  36. const t_search_node *prev = context->fast_encoder->prev;
  37. BYTE *window = context->fast_encoder->window;
  38. t_search_node where;
  39. t_search_node next_where;
  40. int print = 0;
  41. top:
  42. where = lookup[chain_number];
  43. if (print)
  44. printf("Verify chain %d\n", chain_number);
  45. while (where != 0 && bufpos - where < FAST_ENCODER_WINDOW_SIZE)
  46. {
  47. int hash = FAST_ENCODER_RECALCULATE_HASH(where);
  48. BYTE *window = context->fast_encoder->window;
  49. if (print)
  50. printf(" loc %d: char = %3d %3d %3d\n", where, window[where], window[where+1], window[where+2]);
  51. if (hash != chain_number && print == 0)
  52. {
  53. print = 1;
  54. goto top;
  55. }
  56. _ASSERT(hash == chain_number);
  57. next_where = prev[where & FAST_ENCODER_WINDOW_MASK];
  58. if (bufpos - next_where >= FAST_ENCODER_WINDOW_SIZE)
  59. break;
  60. if (next_where >= where && print == 0)
  61. {
  62. print = 1;
  63. goto top;
  64. }
  65. _ASSERT(next_where < where);
  66. where = next_where;
  67. }
  68. }
  69. #endif