| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkDeflate.h" | 8 #include "SkDeflate.h" |
| 9 #include "SkRandom.h" | 9 #include "SkRandom.h" |
| 10 #include "Test.h" | 10 #include "Test.h" |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 #ifdef ZLIB_INCLUDE | 14 #include "zlib.h" |
| 15 #include ZLIB_INCLUDE | |
| 16 #else | |
| 17 #include "zlib.h" | |
| 18 #endif | |
| 19 | 15 |
| 20 // Different zlib implementations use different T. | 16 // Different zlib implementations use different T. |
| 21 // We've seen size_t and unsigned. | 17 // We've seen size_t and unsigned. |
| 22 template <typename T> void* skia_alloc_func(void*, T items, T size) { | 18 template <typename T> void* skia_alloc_func(void*, T items, T size) { |
| 23 return sk_calloc_throw(SkToSizeT(items) * SkToSizeT(size)); | 19 return sk_calloc_throw(SkToSizeT(items) * SkToSizeT(size)); |
| 24 } | 20 } |
| 25 | 21 |
| 26 void skia_free_func(void*, void* address) { sk_free(address); } | 22 void skia_free_func(void*, void* address) { sk_free(address); } |
| 27 | 23 |
| 28 /** | 24 /** |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 uint8_t c; | 153 uint8_t c; |
| 158 SkDEBUGCODE(size_t rb =)decompressed->read(&c, sizeof(uint8_t)); | 154 SkDEBUGCODE(size_t rb =)decompressed->read(&c, sizeof(uint8_t)); |
| 159 SkASSERT(sizeof(uint8_t) == rb); | 155 SkASSERT(sizeof(uint8_t) == rb); |
| 160 if (buffer[i] != c) { | 156 if (buffer[i] != c) { |
| 161 ERRORF(r, "Decompression failed at byte %u.", (unsigned)i); | 157 ERRORF(r, "Decompression failed at byte %u.", (unsigned)i); |
| 162 break; | 158 break; |
| 163 } | 159 } |
| 164 } | 160 } |
| 165 } | 161 } |
| 166 } | 162 } |
| OLD | NEW |