mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-31 02:48:31 +00:00
Use auto when initialializing with new
This commit is contained in:
parent
d0682f0f60
commit
41ec7eda54
@ -166,7 +166,7 @@ add_page(
|
||||
// mode. Since we are not specifying, QPDFWriter will compress
|
||||
// with /FlateDecode if we don't provide any other form of
|
||||
// compression.
|
||||
ImageProvider* p = new ImageProvider(color_space, filter);
|
||||
auto* p = new ImageProvider(color_space, filter);
|
||||
std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider(p);
|
||||
size_t width = p->getWidth();
|
||||
size_t height = p->getHeight();
|
||||
@ -286,7 +286,7 @@ check(
|
||||
if (!this_errors) {
|
||||
// Check image data
|
||||
auto actual_data = image.getStreamData(qpdf_dl_all);
|
||||
ImageProvider* p = new ImageProvider(desired_color_space, "null");
|
||||
auto* p = new ImageProvider(desired_color_space, "null");
|
||||
std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider(p);
|
||||
Pl_Buffer b_p("get image data");
|
||||
provider->provideStreamData(QPDFObjGen(), &b_p);
|
||||
|
@ -409,7 +409,7 @@ process(
|
||||
// Create a single StreamReplacer instance. The interface requires
|
||||
// a std::shared_ptr in various places, so allocate a StreamReplacer
|
||||
// and stash it in a std::shared_ptr.
|
||||
StreamReplacer* replacer = new StreamReplacer(&qpdf);
|
||||
auto* replacer = new StreamReplacer(&qpdf);
|
||||
std::shared_ptr<QPDFObjectHandle::StreamDataProvider> p(replacer);
|
||||
|
||||
for (auto& o: qpdf.getAllObjects()) {
|
||||
|
@ -124,7 +124,7 @@ main(int argc, char* argv[])
|
||||
QPDF qpdf;
|
||||
qpdf.processFile(infilename, password);
|
||||
|
||||
ImageInverter* inv = new ImageInverter;
|
||||
auto* inv = new ImageInverter;
|
||||
auto p = std::shared_ptr<QPDFObjectHandle::StreamDataProvider>(inv);
|
||||
|
||||
// For each page...
|
||||
|
@ -45,7 +45,7 @@ Pl_Buffer::getBuffer()
|
||||
}
|
||||
|
||||
auto size = this->m->data.length();
|
||||
Buffer* b = new Buffer(size);
|
||||
auto* b = new Buffer(size);
|
||||
if (size > 0) {
|
||||
unsigned char* p = b->getBuffer();
|
||||
memcpy(p, this->m->data.data(), size);
|
||||
|
@ -264,7 +264,7 @@ QPDF::create()
|
||||
void
|
||||
QPDF::processFile(char const* filename, char const* password)
|
||||
{
|
||||
FileInputSource* fi = new FileInputSource(filename);
|
||||
auto* fi = new FileInputSource(filename);
|
||||
processInputSource(std::shared_ptr<InputSource>(fi), password);
|
||||
}
|
||||
|
||||
@ -272,7 +272,7 @@ void
|
||||
QPDF::processFile(
|
||||
char const* description, FILE* filep, bool close_file, char const* password)
|
||||
{
|
||||
FileInputSource* fi = new FileInputSource(description, filep, close_file);
|
||||
auto* fi = new FileInputSource(description, filep, close_file);
|
||||
processInputSource(std::shared_ptr<InputSource>(fi), password);
|
||||
}
|
||||
|
||||
|
@ -997,7 +997,7 @@ void
|
||||
QPDFWriter::activatePipelineStack(PipelinePopper& pp)
|
||||
{
|
||||
std::string stack_id("stack " + std::to_string(this->m->next_stack_id));
|
||||
Pl_Count* c =
|
||||
auto* c =
|
||||
new Pl_Count(stack_id.c_str(), this->m->pipeline_stack.back());
|
||||
++this->m->next_stack_id;
|
||||
this->m->pipeline_stack.push_back(c);
|
||||
@ -1030,7 +1030,7 @@ QPDFWriter::PipelinePopper::~PipelinePopper()
|
||||
qw->m->md5_pipeline = nullptr;
|
||||
}
|
||||
qw->m->pipeline_stack.pop_back();
|
||||
Pl_Buffer* buf = dynamic_cast<Pl_Buffer*>(p);
|
||||
auto* buf = dynamic_cast<Pl_Buffer*>(p);
|
||||
if (bp && buf) {
|
||||
*bp = buf->getBufferSharedPointer();
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ QPDF_Array::copy(bool shallow)
|
||||
return do_create(new QPDF_Array(*this));
|
||||
} else {
|
||||
if (sparse) {
|
||||
QPDF_Array* result = new QPDF_Array();
|
||||
auto* result = new QPDF_Array();
|
||||
result->sp_size = sp_size;
|
||||
for (auto const& element: sp_elements) {
|
||||
auto const& obj = element.second;
|
||||
|
@ -106,7 +106,7 @@ qpdf_data
|
||||
qpdf_init()
|
||||
{
|
||||
QTC::TC("qpdf", "qpdf-c called qpdf_init");
|
||||
qpdf_data qpdf = new _qpdf_data();
|
||||
auto qpdf = new _qpdf_data();
|
||||
qpdf->qpdf = QPDF::create();
|
||||
return qpdf;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ main(int argc, char* argv[])
|
||||
|
||||
FILE* infile = QUtil::safe_fopen(infilename, "rb");
|
||||
FILE* outfile = QUtil::safe_fopen(outfilename, "wb");
|
||||
unsigned char* key = new unsigned char[keylen];
|
||||
auto* key = new unsigned char[keylen];
|
||||
for (unsigned int i = 0; i < strlen(hexkey); i += 2) {
|
||||
char t[3];
|
||||
t[0] = hexkey[i];
|
||||
@ -85,8 +85,8 @@ main(int argc, char* argv[])
|
||||
key[i / 2] = static_cast<unsigned char>(val);
|
||||
}
|
||||
|
||||
Pl_StdioFile* out = new Pl_StdioFile("stdout", outfile);
|
||||
Pl_AES_PDF* aes = new Pl_AES_PDF("aes_128_cbc", out, encrypt, key, keylen);
|
||||
auto* out = new Pl_StdioFile("stdout", outfile);
|
||||
auto* aes = new Pl_AES_PDF("aes_128_cbc", out, encrypt, key, keylen);
|
||||
delete[] key;
|
||||
key = nullptr;
|
||||
if (!cbc_mode) {
|
||||
|
@ -141,7 +141,7 @@ test()
|
||||
|
||||
unsigned char ch = 0;
|
||||
bit_offset = 7;
|
||||
Pl_Buffer* bp = new Pl_Buffer("buffer");
|
||||
auto* bp = new Pl_Buffer("buffer");
|
||||
|
||||
test_write_bits(ch, bit_offset, 30UL, 5, bp);
|
||||
test_write_bits(ch, bit_offset, 10UL, 4, bp);
|
||||
|
@ -28,7 +28,7 @@ run(char const* filename)
|
||||
Pipeline* inf2 = new Pl_Flate("inf2", out2, Pl_Flate::a_inflate);
|
||||
|
||||
// Count bytes written to o3
|
||||
Pl_Count* count3 = new Pl_Count("count3", out3);
|
||||
auto* count3 = new Pl_Count("count3", out3);
|
||||
|
||||
// Do both simultaneously
|
||||
Pipeline* inf3 = new Pl_Flate("inf3", count3, Pl_Flate::a_inflate);
|
||||
|
@ -72,7 +72,7 @@ test_ph()
|
||||
ObjectHolder oh0;
|
||||
{
|
||||
std::cout << "hello" << std::endl;
|
||||
Object* o1 = new Object;
|
||||
auto* o1 = new Object;
|
||||
ObjectHolder oh1(o1);
|
||||
std::cout << "oh1 refcount = " << oh1.getRefcount() << std::endl;
|
||||
ObjectHolder oh2(oh1);
|
||||
@ -95,7 +95,7 @@ test_ph()
|
||||
}
|
||||
ol1.push_back(oh3);
|
||||
ol1.push_back(oh3);
|
||||
Object* o3 = new Object;
|
||||
auto* o3 = new Object;
|
||||
oh0 = o3;
|
||||
PointerHolder<Object const> oh6(new Object());
|
||||
oh6->hello();
|
||||
|
@ -41,7 +41,7 @@ main(int argc, char* argv[])
|
||||
char* outfilename = argv[3];
|
||||
unsigned int hexkeylen = QIntC::to_uint(strlen(hexkey));
|
||||
unsigned int keylen = hexkeylen / 2;
|
||||
unsigned char* key = new unsigned char[keylen + 1];
|
||||
auto* key = new unsigned char[keylen + 1];
|
||||
key[keylen] = '\0';
|
||||
|
||||
FILE* infile = QUtil::safe_fopen(infilename, "rb");
|
||||
@ -56,9 +56,9 @@ main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
FILE* outfile = QUtil::safe_fopen(outfilename, "wb");
|
||||
Pl_StdioFile* out = new Pl_StdioFile("stdout", outfile);
|
||||
auto* out = new Pl_StdioFile("stdout", outfile);
|
||||
// Use a small buffer size (64) for testing
|
||||
Pl_RC4* rc4 = new Pl_RC4("rc4", out, key, QIntC::to_int(keylen), 64U);
|
||||
auto* rc4 = new Pl_RC4("rc4", out, key, QIntC::to_int(keylen), 64U);
|
||||
delete[] key;
|
||||
|
||||
// 64 < buffer size < 512, buffer_size is not a power of 2 for testing
|
||||
|
@ -499,7 +499,7 @@ test_8(QPDF& pdf, char const* arg2)
|
||||
auto b = p1.getBufferSharedPointer();
|
||||
// This is a bogus way to use StreamDataProvider, but it does
|
||||
// adequately test its functionality.
|
||||
Provider* provider = new Provider(b);
|
||||
auto* provider = new Provider(b);
|
||||
auto p = std::shared_ptr<QPDFObjectHandle::StreamDataProvider>(provider);
|
||||
qstream.replaceStreamData(
|
||||
p,
|
||||
@ -1068,7 +1068,7 @@ test_27(QPDF& pdf, char const* arg2)
|
||||
pl.writeCStr("new data for stream\n");
|
||||
pl.finish();
|
||||
auto b = pl.getBufferSharedPointer();
|
||||
Provider* provider = new Provider(b);
|
||||
auto* provider = new Provider(b);
|
||||
p1 = decltype(p1)(provider);
|
||||
}
|
||||
// Create a stream that uses a provider in empty1 and copy it
|
||||
@ -1095,7 +1095,7 @@ test_27(QPDF& pdf, char const* arg2)
|
||||
pl.writeCStr("more data for stream\n");
|
||||
pl.finish();
|
||||
auto b = pl.getBufferSharedPointer();
|
||||
Provider* provider = new Provider(b);
|
||||
auto* provider = new Provider(b);
|
||||
p2 = decltype(p2)(provider);
|
||||
}
|
||||
QPDF empty3;
|
||||
|
@ -218,7 +218,7 @@ create_pdf(char const* filename)
|
||||
image_dict.replaceKey("/BitsPerComponent", newInteger(8));
|
||||
image_dict.replaceKey("/Width", newInteger(width));
|
||||
image_dict.replaceKey("/Height", newInteger(height));
|
||||
ImageProvider* p = new ImageProvider(pageno);
|
||||
auto* p = new ImageProvider(pageno);
|
||||
std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider(p);
|
||||
image.replaceStreamData(
|
||||
provider, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
|
||||
|
@ -190,7 +190,7 @@ process(char const* filename, bool include_ignorable, size_t max_len)
|
||||
std::shared_ptr<InputSource> is;
|
||||
|
||||
// Tokenize file, skipping streams
|
||||
FileInputSource* fis = new FileInputSource(filename);
|
||||
auto* fis = new FileInputSource(filename);
|
||||
is = std::shared_ptr<InputSource>(fis);
|
||||
dump_tokens(is, "FILE", max_len, include_ignorable, true, false);
|
||||
|
||||
@ -203,7 +203,7 @@ process(char const* filename, bool include_ignorable, size_t max_len)
|
||||
Pl_Buffer plb("buffer");
|
||||
page.pipeContents(&plb);
|
||||
auto content_data = plb.getBufferSharedPointer();
|
||||
BufferInputSource* bis =
|
||||
auto* bis =
|
||||
new BufferInputSource("content data", content_data.get());
|
||||
is = std::shared_ptr<InputSource>(bis);
|
||||
dump_tokens(
|
||||
@ -220,7 +220,7 @@ process(char const* filename, bool include_ignorable, size_t max_len)
|
||||
if (obj.isStream() && obj.getDict().getKey("/Type").isName() &&
|
||||
obj.getDict().getKey("/Type").getName() == "/ObjStm") {
|
||||
std::shared_ptr<Buffer> b = obj.getStreamData(qpdf_dl_specialized);
|
||||
BufferInputSource* bis =
|
||||
auto* bis =
|
||||
new BufferInputSource("object stream data", b.get());
|
||||
is = std::shared_ptr<InputSource>(bis);
|
||||
dump_tokens(
|
||||
|
Loading…
x
Reference in New Issue
Block a user