2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-05-29 00:10:54 +00:00

Use make_array_pointer_holder

This will be able to be replaced with QUtil::make_shared_array
This commit is contained in:
Jay Berkenbilt 2022-02-07 11:29:12 -05:00
parent 40f1946df8
commit 3f22bea084
4 changed files with 12 additions and 9 deletions

View File

@ -1,6 +1,8 @@
#include <qpdf/Pl_PNGFilter.hh>
#include <qpdf/QTC.hh>
#include <qpdf/QUtil.hh>
#include <stdexcept>
#include <string.h>
#include <limits.h>
@ -46,10 +48,10 @@ Pl_PNGFilter::Pl_PNGFilter(char const* identifier, Pipeline* next,
"PNGFilter created with invalid columns value");
}
this->bytes_per_row = bpr & UINT_MAX;
this->buf1 = PointerHolder<unsigned char>(
true, new unsigned char[this->bytes_per_row + 1]);
this->buf2 = PointerHolder<unsigned char>(
true, new unsigned char[this->bytes_per_row + 1]);
this->buf1 = make_array_pointer_holder<unsigned char>(
this->bytes_per_row + 1);
this->buf2 = make_array_pointer_holder<unsigned char>(
this->bytes_per_row + 1);
memset(this->buf1.get(), 0, this->bytes_per_row + 1);
memset(this->buf2.get(), 0, this->bytes_per_row + 1);
this->cur_row = this->buf1.get();

View File

@ -9,8 +9,7 @@ Pl_RC4::Pl_RC4(char const* identifier, Pipeline* next,
out_bufsize(out_bufsize),
rc4(key_data, key_len)
{
this->outbuf = PointerHolder<unsigned char>(
true, new unsigned char[out_bufsize]);
this->outbuf = make_array_pointer_holder<unsigned char>(out_bufsize);
}
Pl_RC4::~Pl_RC4()

View File

@ -3,6 +3,8 @@
#include <qpdf/QTC.hh>
#include <qpdf/BitStream.hh>
#include <qpdf/BitWriter.hh>
#include <qpdf/QUtil.hh>
#include <stdexcept>
#include <vector>
#include <string.h>
@ -38,8 +40,8 @@ Pl_TIFFPredictor::Pl_TIFFPredictor(char const* identifier, Pipeline* next,
"TIFFPredictor created with invalid columns value");
}
this->bytes_per_row = bpr & UINT_MAX;
this->cur_row = PointerHolder<unsigned char>(
true, new unsigned char[this->bytes_per_row]);
this->cur_row = make_array_pointer_holder<unsigned char>(
this->bytes_per_row);
memset(this->cur_row.get(), 0, this->bytes_per_row);
}

View File

@ -1269,7 +1269,7 @@ QUtil::read_file_into_memory(
fseek(f, 0, SEEK_END);
size = QIntC::to_size(QUtil::tell(f));
fseek(f, 0, SEEK_SET);
file_buf = PointerHolder<char>(true, new char[size]);
file_buf = make_array_pointer_holder<char>(size);
char* buf_p = file_buf.get();
size_t bytes_read = 0;
size_t len = 0;