mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 10:58:58 +00:00
Replace PointerHolder arrays with shared_ptr arrays where possible
Replace PointerHolder arrays wherever it can be done without breaking ABI.
This commit is contained in:
parent
dd4f30226f
commit
40f1946df8
@ -24,6 +24,7 @@
|
||||
|
||||
#include <qpdf/Pipeline.hh>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
class Pl_Flate: public Pipeline
|
||||
{
|
||||
@ -73,7 +74,7 @@ class Pl_Flate: public Pipeline
|
||||
Members(size_t out_bufsize, action_e action);
|
||||
Members(Members const&);
|
||||
|
||||
PointerHolder<unsigned char> outbuf;
|
||||
std::shared_ptr<unsigned char> outbuf;
|
||||
size_t out_bufsize;
|
||||
action_e action;
|
||||
bool initialized;
|
||||
|
@ -37,8 +37,8 @@ InputSource::readLine(size_t max_line_length)
|
||||
// point to position the file had when this method was called.
|
||||
|
||||
qpdf_offset_t offset = this->tell();
|
||||
char* buf = new char[max_line_length + 1];
|
||||
PointerHolder<char> bp(true, buf);
|
||||
auto bp = std::make_unique<char[]>(max_line_length + 1);
|
||||
char* buf = bp.get();
|
||||
memset(buf, '\0', max_line_length + 1);
|
||||
this->read(buf, max_line_length);
|
||||
this->seek(offset, SEEK_SET);
|
||||
|
@ -283,8 +283,7 @@ Pl_DCT::compress(void* cinfo_p, Buffer* b)
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
static int const BUF_SIZE = 65536;
|
||||
PointerHolder<unsigned char> outbuffer_ph(
|
||||
true, new unsigned char[BUF_SIZE]);
|
||||
auto outbuffer_ph = std::make_unique<unsigned char[]>(BUF_SIZE);
|
||||
unsigned char* outbuffer = outbuffer_ph.get();
|
||||
jpeg_pipeline_dest(cinfo, outbuffer, BUF_SIZE, this->getNext());
|
||||
|
||||
|
@ -16,8 +16,7 @@ Pl_Flate::Members::Members(size_t out_bufsize,
|
||||
initialized(false),
|
||||
zdata(0)
|
||||
{
|
||||
this->outbuf = PointerHolder<unsigned char>(
|
||||
true, new unsigned char[out_bufsize]);
|
||||
this->outbuf = QUtil::make_shared_array<unsigned char>(out_bufsize);
|
||||
// Indirect through zdata to reach the z_stream so we don't have
|
||||
// to include zlib.h in Pl_Flate.hh. This means people using
|
||||
// shared library versions of qpdf don't have to have zlib
|
||||
|
@ -204,8 +204,7 @@ iterate_rc4(unsigned char* data, size_t data_len,
|
||||
unsigned char* okey, int key_len,
|
||||
int iterations, bool reverse)
|
||||
{
|
||||
PointerHolder<unsigned char> key_ph = PointerHolder<unsigned char>(
|
||||
true, new unsigned char[QIntC::to_size(key_len)]);
|
||||
auto key_ph = std::make_unique<unsigned char[]>(QIntC::to_size(key_len));
|
||||
unsigned char* key = key_ph.get();
|
||||
for (int i = 0; i < iterations; ++i)
|
||||
{
|
||||
|
@ -97,9 +97,9 @@ QPDF::isLinearized()
|
||||
// Add a byte for a null terminator.
|
||||
static int const tbuf_size = 1025;
|
||||
|
||||
char* buf = new char[tbuf_size];
|
||||
auto b = std::make_unique<char[]>(tbuf_size);
|
||||
char* buf = b.get();
|
||||
this->m->file->seek(0, SEEK_SET);
|
||||
PointerHolder<char> b(true, buf);
|
||||
memset(buf, '\0', tbuf_size);
|
||||
this->m->file->read(buf, tbuf_size - 1);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user