Commit 3f22bea084d8d64cba1a433726abd709caf8456b

Authored by Jay Berkenbilt
1 parent 40f1946d

Use make_array_pointer_holder

This will be able to be replaced with QUtil::make_shared_array
libqpdf/Pl_PNGFilter.cc
1 #include <qpdf/Pl_PNGFilter.hh> 1 #include <qpdf/Pl_PNGFilter.hh>
2 2
3 #include <qpdf/QTC.hh> 3 #include <qpdf/QTC.hh>
  4 +#include <qpdf/QUtil.hh>
  5 +
4 #include <stdexcept> 6 #include <stdexcept>
5 #include <string.h> 7 #include <string.h>
6 #include <limits.h> 8 #include <limits.h>
@@ -46,10 +48,10 @@ Pl_PNGFilter::Pl_PNGFilter(char const* identifier, Pipeline* next, @@ -46,10 +48,10 @@ Pl_PNGFilter::Pl_PNGFilter(char const* identifier, Pipeline* next,
46 "PNGFilter created with invalid columns value"); 48 "PNGFilter created with invalid columns value");
47 } 49 }
48 this->bytes_per_row = bpr & UINT_MAX; 50 this->bytes_per_row = bpr & UINT_MAX;
49 - this->buf1 = PointerHolder<unsigned char>(  
50 - true, new unsigned char[this->bytes_per_row + 1]);  
51 - this->buf2 = PointerHolder<unsigned char>(  
52 - true, new unsigned char[this->bytes_per_row + 1]); 51 + this->buf1 = make_array_pointer_holder<unsigned char>(
  52 + this->bytes_per_row + 1);
  53 + this->buf2 = make_array_pointer_holder<unsigned char>(
  54 + this->bytes_per_row + 1);
53 memset(this->buf1.get(), 0, this->bytes_per_row + 1); 55 memset(this->buf1.get(), 0, this->bytes_per_row + 1);
54 memset(this->buf2.get(), 0, this->bytes_per_row + 1); 56 memset(this->buf2.get(), 0, this->bytes_per_row + 1);
55 this->cur_row = this->buf1.get(); 57 this->cur_row = this->buf1.get();
libqpdf/Pl_RC4.cc
@@ -9,8 +9,7 @@ Pl_RC4::Pl_RC4(char const* identifier, Pipeline* next, @@ -9,8 +9,7 @@ Pl_RC4::Pl_RC4(char const* identifier, Pipeline* next,
9 out_bufsize(out_bufsize), 9 out_bufsize(out_bufsize),
10 rc4(key_data, key_len) 10 rc4(key_data, key_len)
11 { 11 {
12 - this->outbuf = PointerHolder<unsigned char>(  
13 - true, new unsigned char[out_bufsize]); 12 + this->outbuf = make_array_pointer_holder<unsigned char>(out_bufsize);
14 } 13 }
15 14
16 Pl_RC4::~Pl_RC4() 15 Pl_RC4::~Pl_RC4()
libqpdf/Pl_TIFFPredictor.cc
@@ -3,6 +3,8 @@ @@ -3,6 +3,8 @@
3 #include <qpdf/QTC.hh> 3 #include <qpdf/QTC.hh>
4 #include <qpdf/BitStream.hh> 4 #include <qpdf/BitStream.hh>
5 #include <qpdf/BitWriter.hh> 5 #include <qpdf/BitWriter.hh>
  6 +#include <qpdf/QUtil.hh>
  7 +
6 #include <stdexcept> 8 #include <stdexcept>
7 #include <vector> 9 #include <vector>
8 #include <string.h> 10 #include <string.h>
@@ -38,8 +40,8 @@ Pl_TIFFPredictor::Pl_TIFFPredictor(char const* identifier, Pipeline* next, @@ -38,8 +40,8 @@ Pl_TIFFPredictor::Pl_TIFFPredictor(char const* identifier, Pipeline* next,
38 "TIFFPredictor created with invalid columns value"); 40 "TIFFPredictor created with invalid columns value");
39 } 41 }
40 this->bytes_per_row = bpr & UINT_MAX; 42 this->bytes_per_row = bpr & UINT_MAX;
41 - this->cur_row = PointerHolder<unsigned char>(  
42 - true, new unsigned char[this->bytes_per_row]); 43 + this->cur_row = make_array_pointer_holder<unsigned char>(
  44 + this->bytes_per_row);
43 memset(this->cur_row.get(), 0, this->bytes_per_row); 45 memset(this->cur_row.get(), 0, this->bytes_per_row);
44 } 46 }
45 47
libqpdf/QUtil.cc
@@ -1269,7 +1269,7 @@ QUtil::read_file_into_memory( @@ -1269,7 +1269,7 @@ QUtil::read_file_into_memory(
1269 fseek(f, 0, SEEK_END); 1269 fseek(f, 0, SEEK_END);
1270 size = QIntC::to_size(QUtil::tell(f)); 1270 size = QIntC::to_size(QUtil::tell(f));
1271 fseek(f, 0, SEEK_SET); 1271 fseek(f, 0, SEEK_SET);
1272 - file_buf = PointerHolder<char>(true, new char[size]); 1272 + file_buf = make_array_pointer_holder<char>(size);
1273 char* buf_p = file_buf.get(); 1273 char* buf_p = file_buf.get();
1274 size_t bytes_read = 0; 1274 size_t bytes_read = 0;
1275 size_t len = 0; 1275 size_t len = 0;