Changeset 740 for vendor/current/lib/compression
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- Location:
- vendor/current/lib/compression
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/lib/compression/lzxpress.c
r414 r740 35 35 #include "replace.h" 36 36 #include "lzxpress.h" 37 #include "../lib/util/byteorder.h" 37 38 38 39 … … 81 82 uncompressed_pos = 0; 82 83 indic = 0; 84 *(uint32_t *)compressed = 0; 83 85 compressed_pos = sizeof(uint32_t); 84 86 indic_pos = &compressed[0]; … … 130 132 /* Classical meta-data */ 131 133 metadata = (uint16_t)(((best_offset - 1) << 3) | (best_len - 3)); 132 dest[metadata_size / sizeof(uint16_t)] = metadata;134 SSVAL(dest, metadata_size / sizeof(uint16_t), metadata); 133 135 metadata_size += sizeof(uint16_t); 134 136 } else { 135 137 metadata = (uint16_t)(((best_offset - 1) << 3) | 7); 136 dest[metadata_size / sizeof(uint16_t)] = metadata;138 SSVAL(dest, metadata_size / sizeof(uint16_t), metadata); 137 139 metadata_size = sizeof(uint16_t); 138 140 … … 156 158 } 157 159 158 /* Addition nal best_len */160 /* Additional best_len */ 159 161 compressed[compressed_pos + metadata_size] = (best_len - (3 + 7 + 15)) & 0xFF; 160 162 metadata_size += sizeof(uint8_t); … … 168 170 } 169 171 170 /* Addition nal best_len */172 /* Additional best_len */ 171 173 compressed[compressed_pos + metadata_size] = 255; 172 174 … … 199 201 200 202 if ((indic_bit - 1) % 32 > (indic_bit % 32)) { 201 *(uint32_t *)indic_pos = indic;203 SIVAL(indic_pos, 0, indic); 202 204 indic = 0; 203 205 indic_pos = &compressed[compressed_pos]; … … 213 215 compressed_pos++; 214 216 if (((indic_bit - 1) % 32) > (indic_bit % 32)){ 215 *(uint32_t *)indic_pos = indic;217 SIVAL(indic_pos, 0, indic); 216 218 indic = 0; 217 219 indic_pos = &compressed[compressed_pos]; … … 224 226 indic |= 0 << (32 - ((indic_bit % 32) + 1)); 225 227 226 *(uint32_t *)indic_pos = indic; 228 *(uint32_t *)&compressed[compressed_pos] = 0; 229 SIVAL(indic_pos, 0, indic); 227 230 compressed_pos += sizeof(uint32_t); 228 231 } -
vendor/current/lib/compression/testsuite.c
r414 r740 21 21 #include "includes.h" 22 22 #include "torture/torture.h" 23 #include "../compression/mszip.h" 23 #include "talloc.h" 24 #include "mszip.h" 25 #include "lzxpress.h" 26 27 /* 28 test lzxpress 29 */ 30 static bool test_lzxpress(struct torture_context *test) 31 { 32 TALLOC_CTX *tmp_ctx = talloc_new(test); 33 uint8_t *data; 34 const char *fixed_data = "this is a test. and this is a test too"; 35 const uint8_t fixed_out[] = { 0x00, 0x20, 0x00, 0x04, 0x74, 0x68, 0x69, 0x73, 36 0x20, 0x10, 0x00, 0x61, 0x20, 0x74, 0x65, 0x73, 37 0x74, 0x2E, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x9F, 38 0x00, 0x04, 0x20, 0x74, 0x6F, 0x6F, 0x00, 0x00, 39 0x00, 0x00 }; 40 ssize_t c_size; 41 uint8_t *out, *out2; 42 43 data = talloc_size(tmp_ctx, 1023); 44 out = talloc_size(tmp_ctx, 2048); 45 memset(out, 0x42, talloc_get_size(out)); 46 47 torture_comment(test, "lzxpress fixed compression\n"); 48 c_size = lzxpress_compress((const uint8_t *)fixed_data, 49 strlen(fixed_data), 50 out, 51 talloc_get_size(out)); 52 53 torture_assert_int_equal(test, c_size, sizeof(fixed_out), "fixed lzxpress_compress size"); 54 torture_assert_mem_equal(test, out, fixed_out, c_size, "fixed lzxpress_compress data"); 55 56 torture_comment(test, "lzxpress fixed decompression\n"); 57 out2 = talloc_size(tmp_ctx, strlen(fixed_data)); 58 c_size = lzxpress_decompress(out, 59 sizeof(fixed_out), 60 out2, 61 talloc_get_size(out2)); 62 63 torture_assert_int_equal(test, c_size, strlen(fixed_data), "fixed lzxpress_decompress size"); 64 torture_assert_mem_equal(test, out2, fixed_data, c_size, "fixed lzxpress_decompress data"); 65 66 return true; 67 } 68 24 69 25 70 struct torture_suite *torture_local_compression(TALLOC_CTX *mem_ctx) 26 71 { 27 struct torture_suite *suite = torture_suite_create(mem_ctx, "COMPRESSION"); 72 struct torture_suite *suite = torture_suite_create(mem_ctx, "compression"); 73 74 torture_suite_add_simple_test(suite, "lzxpress", test_lzxpress); 28 75 29 76 return suite;
Note:
See TracChangeset
for help on using the changeset viewer.