Commit 902fd6df71e89127fdf82a1a309c9c24927276c7

Authored by m-holger
1 parent 6b80e0f1

Change Pl_TIFFPredictor::cur_row to std::vector<unsigned char>

libqpdf/Pl_TIFFPredictor.cc
... ... @@ -35,8 +35,7 @@ Pl_TIFFPredictor::Pl_TIFFPredictor(
35 35 throw std::runtime_error("TIFFPredictor created with invalid columns value");
36 36 }
37 37 this->bytes_per_row = bpr & UINT_MAX;
38   - this->cur_row = QUtil::make_shared_array<unsigned char>(this->bytes_per_row);
39   - memset(this->cur_row.get(), 0, this->bytes_per_row);
  38 + this->cur_row.assign(this->bytes_per_row, 0);
40 39 }
41 40  
42 41 void
... ... @@ -46,19 +45,19 @@ Pl_TIFFPredictor::write(unsigned char const* data, size_t len)
46 45 size_t offset = 0;
47 46 while (len >= left) {
48 47 // finish off current row
49   - memcpy(this->cur_row.get() + this->pos, data + offset, left);
  48 + memcpy(this->cur_row.data() + this->pos, data + offset, left);
50 49 offset += left;
51 50 len -= left;
52 51  
53 52 processRow();
54 53  
55 54 // Prepare for next row
56   - memset(this->cur_row.get(), 0, this->bytes_per_row);
  55 + this->cur_row.assign(this->bytes_per_row, 0);
57 56 left = this->bytes_per_row;
58 57 this->pos = 0;
59 58 }
60 59 if (len) {
61   - memcpy(this->cur_row.get() + this->pos, data + offset, len);
  60 + memcpy(this->cur_row.data() + this->pos, data + offset, len);
62 61 }
63 62 this->pos += len;
64 63 }
... ... @@ -68,7 +67,7 @@ Pl_TIFFPredictor::processRow()
68 67 {
69 68 QTC::TC("libtests", "Pl_TIFFPredictor processRow", (action == a_decode ? 0 : 1));
70 69 BitWriter bw(this->getNext());
71   - BitStream in(this->cur_row.get(), this->bytes_per_row);
  70 + BitStream in(this->cur_row.data(), this->bytes_per_row);
72 71 std::vector<long long> prev;
73 72 for (unsigned int i = 0; i < this->samples_per_pixel; ++i) {
74 73 long long sample = in.getBitsSigned(this->bits_per_sample);
... ... @@ -100,6 +99,6 @@ Pl_TIFFPredictor::finish()
100 99 processRow();
101 100 }
102 101 this->pos = 0;
103   - memset(this->cur_row.get(), 0, this->bytes_per_row);
  102 + this->cur_row.assign(this->bytes_per_row, 0);
104 103 getNext()->finish();
105 104 }
... ...
libqpdf/qpdf/Pl_TIFFPredictor.hh
... ... @@ -6,6 +6,8 @@
6 6  
7 7 #include <qpdf/Pipeline.hh>
8 8  
  9 +#include<vector>
  10 +
9 11 class Pl_TIFFPredictor: public Pipeline
10 12 {
11 13 public:
... ... @@ -31,7 +33,7 @@ class Pl_TIFFPredictor: public Pipeline
31 33 unsigned int bytes_per_row;
32 34 unsigned int samples_per_pixel;
33 35 unsigned int bits_per_sample;
34   - std::shared_ptr<unsigned char> cur_row;
  36 + std::vector<unsigned char> cur_row;
35 37 size_t pos;
36 38 };
37 39  
... ...