Subversion Repositories SvarDOS

Rev

Rev 340 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 340 Rev 341
Line 76... Line 76...
76
 
76
 
77
  for (trycount = 0; trycount < 30000; trycount++) {
77
  for (trycount = 0; trycount < 30000; trycount++) {
78
    size_t bytesprocessed = 0;
78
    size_t bytesprocessed = 0;
79
    size_t file_decoded_len = 0;
79
    size_t file_decoded_len = 0;
80
    int maxchunksz;
80
    int maxchunksz;
-
 
81
    struct unchunk_state unchstate = {0};
81
 
82
 
82
    /* segment file into chunks of random size */
83
    /* segment file into chunks of random size */
83
    maxchunksz = (rand() % 256) + 8;
84
    maxchunksz = (rand() % 256) + 8;
84
    file_chunked_len = randchunkdata(file_chunked, file_raw, file_raw_len, maxchunksz);
85
    file_chunked_len = randchunkdata(file_chunked, file_raw, file_raw_len, maxchunksz);
85
 
86
 
Line 94... Line 95...
94
      if (bytes > file_chunked_len - bytesprocessed) bytes = file_chunked_len - bytesprocessed;
95
      if (bytes > file_chunked_len - bytesprocessed) bytes = file_chunked_len - bytesprocessed;
95
      printf("processing %4zu bytes of chunked data", bytes);
96
      printf("processing %4zu bytes of chunked data", bytes);
96
      memcpy(buffer, file_chunked + bytesprocessed, bytes);
97
      memcpy(buffer, file_chunked + bytesprocessed, bytes);
97
 
98
 
98
      /* decode the chunked version reading random amounts of data and build a decoded version */
99
      /* decode the chunked version reading random amounts of data and build a decoded version */
99
      decodedbytes = unchunk(buffer, bytes);
100
      decodedbytes = unchunk(buffer, bytes, &unchstate);
100
      printf(" -> decoded into %4d raw bytes\r\n", decodedbytes);
101
      printf(" -> decoded into %4d raw bytes\r\n", decodedbytes);
101
      memcpy(file_decoded + file_decoded_len, buffer, decodedbytes);
102
      memcpy(file_decoded + file_decoded_len, buffer, decodedbytes);
102
      file_decoded_len += decodedbytes;
103
      file_decoded_len += decodedbytes;
103
      bytesprocessed += bytes;
104
      bytesprocessed += bytes;
104
      if (bytesprocessed == file_chunked_len) break;
105
      if (bytesprocessed == file_chunked_len) break;