summaryrefslogtreecommitdiff
path: root/core/fxcodec/gif/cfx_lzwdecompressor.h
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-09-28 15:42:07 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-09-28 20:24:06 +0000
commit58418a24debb15019ec71eca193eff02c2a4846c (patch)
tree7596042bd4400bdef9d3bf7536dfabf74af7e03b /core/fxcodec/gif/cfx_lzwdecompressor.h
parent79eab23d8f83aec7088c59f8bcee65994c6662a0 (diff)
downloadpdfium-chromium/3227.tar.xz
Convert LZW decompressor to use vector instead of static arraychromium/3230chromium/3229chromium/3228chromium/3227
Speciifically replacing what was called the "stack_", an array, with a vector called "decompressed_". The fact that this data structure wasn't actually a stack caused a lot of grief when refactoring. BUG=pdfium:903 Change-Id: I056f8fc9183bcde67a03dc9de0dae9ddf9fb0f37 Reviewed-on: https://pdfium-review.googlesource.com/15092 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core/fxcodec/gif/cfx_lzwdecompressor.h')
-rw-r--r--core/fxcodec/gif/cfx_lzwdecompressor.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/core/fxcodec/gif/cfx_lzwdecompressor.h b/core/fxcodec/gif/cfx_lzwdecompressor.h
index 10c0a566d7..717c055973 100644
--- a/core/fxcodec/gif/cfx_lzwdecompressor.h
+++ b/core/fxcodec/gif/cfx_lzwdecompressor.h
@@ -29,11 +29,21 @@ class CFX_LZWDecompressor {
uint8_t* des_buf,
uint32_t* des_size);
+ // Used by unittests, should not be called in production code.
+ uint32_t ExtractDataForTest(uint8_t* des_buf, uint32_t des_size) {
+ return ExtractData(des_buf, des_size);
+ }
+
+ std::vector<uint8_t>* DecompressedForTest() { return &decompressed_; }
+
+ size_t* DecompressedNextForTest() { return &decompressed_next_; }
+
private:
CFX_LZWDecompressor(uint8_t color_exp, uint8_t code_exp);
void ClearTable();
void AddCode(uint16_t prefix_code, uint8_t append_char);
bool DecodeString(uint16_t code);
+ uint32_t ExtractData(uint8_t* des_buf, uint32_t des_size);
uint8_t code_size_;
uint8_t code_size_cur_;
@@ -42,8 +52,8 @@ class CFX_LZWDecompressor {
uint16_t code_end_;
uint16_t code_next_;
uint8_t code_first_;
- uint8_t stack_[GIF_MAX_LZW_CODE];
- size_t stack_size_;
+ std::vector<uint8_t> decompressed_;
+ size_t decompressed_next_;
CodeEntry code_table_[GIF_MAX_LZW_CODE];
uint16_t code_old_;
uint8_t* next_in_;