Commit 41ec7eda54e2263eeb1aee4c3a0616c9c2777fb7
1 parent
d0682f0f
Use auto when initialializing with new
Showing
16 changed files
with
28 additions
and
28 deletions
examples/pdf-create.cc
| @@ -166,7 +166,7 @@ add_page( | @@ -166,7 +166,7 @@ add_page( | ||
| 166 | // mode. Since we are not specifying, QPDFWriter will compress | 166 | // mode. Since we are not specifying, QPDFWriter will compress |
| 167 | // with /FlateDecode if we don't provide any other form of | 167 | // with /FlateDecode if we don't provide any other form of |
| 168 | // compression. | 168 | // compression. |
| 169 | - ImageProvider* p = new ImageProvider(color_space, filter); | 169 | + auto* p = new ImageProvider(color_space, filter); |
| 170 | std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider(p); | 170 | std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider(p); |
| 171 | size_t width = p->getWidth(); | 171 | size_t width = p->getWidth(); |
| 172 | size_t height = p->getHeight(); | 172 | size_t height = p->getHeight(); |
| @@ -286,7 +286,7 @@ check( | @@ -286,7 +286,7 @@ check( | ||
| 286 | if (!this_errors) { | 286 | if (!this_errors) { |
| 287 | // Check image data | 287 | // Check image data |
| 288 | auto actual_data = image.getStreamData(qpdf_dl_all); | 288 | auto actual_data = image.getStreamData(qpdf_dl_all); |
| 289 | - ImageProvider* p = new ImageProvider(desired_color_space, "null"); | 289 | + auto* p = new ImageProvider(desired_color_space, "null"); |
| 290 | std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider(p); | 290 | std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider(p); |
| 291 | Pl_Buffer b_p("get image data"); | 291 | Pl_Buffer b_p("get image data"); |
| 292 | provider->provideStreamData(QPDFObjGen(), &b_p); | 292 | provider->provideStreamData(QPDFObjGen(), &b_p); |
examples/pdf-custom-filter.cc
| @@ -409,7 +409,7 @@ process( | @@ -409,7 +409,7 @@ process( | ||
| 409 | // Create a single StreamReplacer instance. The interface requires | 409 | // Create a single StreamReplacer instance. The interface requires |
| 410 | // a std::shared_ptr in various places, so allocate a StreamReplacer | 410 | // a std::shared_ptr in various places, so allocate a StreamReplacer |
| 411 | // and stash it in a std::shared_ptr. | 411 | // and stash it in a std::shared_ptr. |
| 412 | - StreamReplacer* replacer = new StreamReplacer(&qpdf); | 412 | + auto* replacer = new StreamReplacer(&qpdf); |
| 413 | std::shared_ptr<QPDFObjectHandle::StreamDataProvider> p(replacer); | 413 | std::shared_ptr<QPDFObjectHandle::StreamDataProvider> p(replacer); |
| 414 | 414 | ||
| 415 | for (auto& o: qpdf.getAllObjects()) { | 415 | for (auto& o: qpdf.getAllObjects()) { |
examples/pdf-invert-images.cc
| @@ -124,7 +124,7 @@ main(int argc, char* argv[]) | @@ -124,7 +124,7 @@ main(int argc, char* argv[]) | ||
| 124 | QPDF qpdf; | 124 | QPDF qpdf; |
| 125 | qpdf.processFile(infilename, password); | 125 | qpdf.processFile(infilename, password); |
| 126 | 126 | ||
| 127 | - ImageInverter* inv = new ImageInverter; | 127 | + auto* inv = new ImageInverter; |
| 128 | auto p = std::shared_ptr<QPDFObjectHandle::StreamDataProvider>(inv); | 128 | auto p = std::shared_ptr<QPDFObjectHandle::StreamDataProvider>(inv); |
| 129 | 129 | ||
| 130 | // For each page... | 130 | // For each page... |
libqpdf/Pl_Buffer.cc
| @@ -45,7 +45,7 @@ Pl_Buffer::getBuffer() | @@ -45,7 +45,7 @@ Pl_Buffer::getBuffer() | ||
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | auto size = this->m->data.length(); | 47 | auto size = this->m->data.length(); |
| 48 | - Buffer* b = new Buffer(size); | 48 | + auto* b = new Buffer(size); |
| 49 | if (size > 0) { | 49 | if (size > 0) { |
| 50 | unsigned char* p = b->getBuffer(); | 50 | unsigned char* p = b->getBuffer(); |
| 51 | memcpy(p, this->m->data.data(), size); | 51 | memcpy(p, this->m->data.data(), size); |
libqpdf/QPDF.cc
| @@ -264,7 +264,7 @@ QPDF::create() | @@ -264,7 +264,7 @@ QPDF::create() | ||
| 264 | void | 264 | void |
| 265 | QPDF::processFile(char const* filename, char const* password) | 265 | QPDF::processFile(char const* filename, char const* password) |
| 266 | { | 266 | { |
| 267 | - FileInputSource* fi = new FileInputSource(filename); | 267 | + auto* fi = new FileInputSource(filename); |
| 268 | processInputSource(std::shared_ptr<InputSource>(fi), password); | 268 | processInputSource(std::shared_ptr<InputSource>(fi), password); |
| 269 | } | 269 | } |
| 270 | 270 | ||
| @@ -272,7 +272,7 @@ void | @@ -272,7 +272,7 @@ void | ||
| 272 | QPDF::processFile( | 272 | QPDF::processFile( |
| 273 | char const* description, FILE* filep, bool close_file, char const* password) | 273 | char const* description, FILE* filep, bool close_file, char const* password) |
| 274 | { | 274 | { |
| 275 | - FileInputSource* fi = new FileInputSource(description, filep, close_file); | 275 | + auto* fi = new FileInputSource(description, filep, close_file); |
| 276 | processInputSource(std::shared_ptr<InputSource>(fi), password); | 276 | processInputSource(std::shared_ptr<InputSource>(fi), password); |
| 277 | } | 277 | } |
| 278 | 278 |
libqpdf/QPDFWriter.cc
| @@ -997,7 +997,7 @@ void | @@ -997,7 +997,7 @@ void | ||
| 997 | QPDFWriter::activatePipelineStack(PipelinePopper& pp) | 997 | QPDFWriter::activatePipelineStack(PipelinePopper& pp) |
| 998 | { | 998 | { |
| 999 | std::string stack_id("stack " + std::to_string(this->m->next_stack_id)); | 999 | std::string stack_id("stack " + std::to_string(this->m->next_stack_id)); |
| 1000 | - Pl_Count* c = | 1000 | + auto* c = |
| 1001 | new Pl_Count(stack_id.c_str(), this->m->pipeline_stack.back()); | 1001 | new Pl_Count(stack_id.c_str(), this->m->pipeline_stack.back()); |
| 1002 | ++this->m->next_stack_id; | 1002 | ++this->m->next_stack_id; |
| 1003 | this->m->pipeline_stack.push_back(c); | 1003 | this->m->pipeline_stack.push_back(c); |
| @@ -1030,7 +1030,7 @@ QPDFWriter::PipelinePopper::~PipelinePopper() | @@ -1030,7 +1030,7 @@ QPDFWriter::PipelinePopper::~PipelinePopper() | ||
| 1030 | qw->m->md5_pipeline = nullptr; | 1030 | qw->m->md5_pipeline = nullptr; |
| 1031 | } | 1031 | } |
| 1032 | qw->m->pipeline_stack.pop_back(); | 1032 | qw->m->pipeline_stack.pop_back(); |
| 1033 | - Pl_Buffer* buf = dynamic_cast<Pl_Buffer*>(p); | 1033 | + auto* buf = dynamic_cast<Pl_Buffer*>(p); |
| 1034 | if (bp && buf) { | 1034 | if (bp && buf) { |
| 1035 | *bp = buf->getBufferSharedPointer(); | 1035 | *bp = buf->getBufferSharedPointer(); |
| 1036 | } | 1036 | } |
libqpdf/QPDF_Array.cc
| @@ -83,7 +83,7 @@ QPDF_Array::copy(bool shallow) | @@ -83,7 +83,7 @@ QPDF_Array::copy(bool shallow) | ||
| 83 | return do_create(new QPDF_Array(*this)); | 83 | return do_create(new QPDF_Array(*this)); |
| 84 | } else { | 84 | } else { |
| 85 | if (sparse) { | 85 | if (sparse) { |
| 86 | - QPDF_Array* result = new QPDF_Array(); | 86 | + auto* result = new QPDF_Array(); |
| 87 | result->sp_size = sp_size; | 87 | result->sp_size = sp_size; |
| 88 | for (auto const& element: sp_elements) { | 88 | for (auto const& element: sp_elements) { |
| 89 | auto const& obj = element.second; | 89 | auto const& obj = element.second; |
libqpdf/qpdf-c.cc
| @@ -106,7 +106,7 @@ qpdf_data | @@ -106,7 +106,7 @@ qpdf_data | ||
| 106 | qpdf_init() | 106 | qpdf_init() |
| 107 | { | 107 | { |
| 108 | QTC::TC("qpdf", "qpdf-c called qpdf_init"); | 108 | QTC::TC("qpdf", "qpdf-c called qpdf_init"); |
| 109 | - qpdf_data qpdf = new _qpdf_data(); | 109 | + auto qpdf = new _qpdf_data(); |
| 110 | qpdf->qpdf = QPDF::create(); | 110 | qpdf->qpdf = QPDF::create(); |
| 111 | return qpdf; | 111 | return qpdf; |
| 112 | } | 112 | } |
libtests/aes.cc
| @@ -74,7 +74,7 @@ main(int argc, char* argv[]) | @@ -74,7 +74,7 @@ main(int argc, char* argv[]) | ||
| 74 | 74 | ||
| 75 | FILE* infile = QUtil::safe_fopen(infilename, "rb"); | 75 | FILE* infile = QUtil::safe_fopen(infilename, "rb"); |
| 76 | FILE* outfile = QUtil::safe_fopen(outfilename, "wb"); | 76 | FILE* outfile = QUtil::safe_fopen(outfilename, "wb"); |
| 77 | - unsigned char* key = new unsigned char[keylen]; | 77 | + auto* key = new unsigned char[keylen]; |
| 78 | for (unsigned int i = 0; i < strlen(hexkey); i += 2) { | 78 | for (unsigned int i = 0; i < strlen(hexkey); i += 2) { |
| 79 | char t[3]; | 79 | char t[3]; |
| 80 | t[0] = hexkey[i]; | 80 | t[0] = hexkey[i]; |
| @@ -85,8 +85,8 @@ main(int argc, char* argv[]) | @@ -85,8 +85,8 @@ main(int argc, char* argv[]) | ||
| 85 | key[i / 2] = static_cast<unsigned char>(val); | 85 | key[i / 2] = static_cast<unsigned char>(val); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | - Pl_StdioFile* out = new Pl_StdioFile("stdout", outfile); | ||
| 89 | - Pl_AES_PDF* aes = new Pl_AES_PDF("aes_128_cbc", out, encrypt, key, keylen); | 88 | + auto* out = new Pl_StdioFile("stdout", outfile); |
| 89 | + auto* aes = new Pl_AES_PDF("aes_128_cbc", out, encrypt, key, keylen); | ||
| 90 | delete[] key; | 90 | delete[] key; |
| 91 | key = nullptr; | 91 | key = nullptr; |
| 92 | if (!cbc_mode) { | 92 | if (!cbc_mode) { |
libtests/bits.cc
| @@ -141,7 +141,7 @@ test() | @@ -141,7 +141,7 @@ test() | ||
| 141 | 141 | ||
| 142 | unsigned char ch = 0; | 142 | unsigned char ch = 0; |
| 143 | bit_offset = 7; | 143 | bit_offset = 7; |
| 144 | - Pl_Buffer* bp = new Pl_Buffer("buffer"); | 144 | + auto* bp = new Pl_Buffer("buffer"); |
| 145 | 145 | ||
| 146 | test_write_bits(ch, bit_offset, 30UL, 5, bp); | 146 | test_write_bits(ch, bit_offset, 30UL, 5, bp); |
| 147 | test_write_bits(ch, bit_offset, 10UL, 4, bp); | 147 | test_write_bits(ch, bit_offset, 10UL, 4, bp); |
libtests/flate.cc
| @@ -28,7 +28,7 @@ run(char const* filename) | @@ -28,7 +28,7 @@ run(char const* filename) | ||
| 28 | Pipeline* inf2 = new Pl_Flate("inf2", out2, Pl_Flate::a_inflate); | 28 | Pipeline* inf2 = new Pl_Flate("inf2", out2, Pl_Flate::a_inflate); |
| 29 | 29 | ||
| 30 | // Count bytes written to o3 | 30 | // Count bytes written to o3 |
| 31 | - Pl_Count* count3 = new Pl_Count("count3", out3); | 31 | + auto* count3 = new Pl_Count("count3", out3); |
| 32 | 32 | ||
| 33 | // Do both simultaneously | 33 | // Do both simultaneously |
| 34 | Pipeline* inf3 = new Pl_Flate("inf3", count3, Pl_Flate::a_inflate); | 34 | Pipeline* inf3 = new Pl_Flate("inf3", count3, Pl_Flate::a_inflate); |
libtests/pointer_holder.cc
| @@ -72,7 +72,7 @@ test_ph() | @@ -72,7 +72,7 @@ test_ph() | ||
| 72 | ObjectHolder oh0; | 72 | ObjectHolder oh0; |
| 73 | { | 73 | { |
| 74 | std::cout << "hello" << std::endl; | 74 | std::cout << "hello" << std::endl; |
| 75 | - Object* o1 = new Object; | 75 | + auto* o1 = new Object; |
| 76 | ObjectHolder oh1(o1); | 76 | ObjectHolder oh1(o1); |
| 77 | std::cout << "oh1 refcount = " << oh1.getRefcount() << std::endl; | 77 | std::cout << "oh1 refcount = " << oh1.getRefcount() << std::endl; |
| 78 | ObjectHolder oh2(oh1); | 78 | ObjectHolder oh2(oh1); |
| @@ -95,7 +95,7 @@ test_ph() | @@ -95,7 +95,7 @@ test_ph() | ||
| 95 | } | 95 | } |
| 96 | ol1.push_back(oh3); | 96 | ol1.push_back(oh3); |
| 97 | ol1.push_back(oh3); | 97 | ol1.push_back(oh3); |
| 98 | - Object* o3 = new Object; | 98 | + auto* o3 = new Object; |
| 99 | oh0 = o3; | 99 | oh0 = o3; |
| 100 | PointerHolder<Object const> oh6(new Object()); | 100 | PointerHolder<Object const> oh6(new Object()); |
| 101 | oh6->hello(); | 101 | oh6->hello(); |
libtests/rc4.cc
| @@ -41,7 +41,7 @@ main(int argc, char* argv[]) | @@ -41,7 +41,7 @@ main(int argc, char* argv[]) | ||
| 41 | char* outfilename = argv[3]; | 41 | char* outfilename = argv[3]; |
| 42 | unsigned int hexkeylen = QIntC::to_uint(strlen(hexkey)); | 42 | unsigned int hexkeylen = QIntC::to_uint(strlen(hexkey)); |
| 43 | unsigned int keylen = hexkeylen / 2; | 43 | unsigned int keylen = hexkeylen / 2; |
| 44 | - unsigned char* key = new unsigned char[keylen + 1]; | 44 | + auto* key = new unsigned char[keylen + 1]; |
| 45 | key[keylen] = '\0'; | 45 | key[keylen] = '\0'; |
| 46 | 46 | ||
| 47 | FILE* infile = QUtil::safe_fopen(infilename, "rb"); | 47 | FILE* infile = QUtil::safe_fopen(infilename, "rb"); |
| @@ -56,9 +56,9 @@ main(int argc, char* argv[]) | @@ -56,9 +56,9 @@ main(int argc, char* argv[]) | ||
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | FILE* outfile = QUtil::safe_fopen(outfilename, "wb"); | 58 | FILE* outfile = QUtil::safe_fopen(outfilename, "wb"); |
| 59 | - Pl_StdioFile* out = new Pl_StdioFile("stdout", outfile); | 59 | + auto* out = new Pl_StdioFile("stdout", outfile); |
| 60 | // Use a small buffer size (64) for testing | 60 | // Use a small buffer size (64) for testing |
| 61 | - Pl_RC4* rc4 = new Pl_RC4("rc4", out, key, QIntC::to_int(keylen), 64U); | 61 | + auto* rc4 = new Pl_RC4("rc4", out, key, QIntC::to_int(keylen), 64U); |
| 62 | delete[] key; | 62 | delete[] key; |
| 63 | 63 | ||
| 64 | // 64 < buffer size < 512, buffer_size is not a power of 2 for testing | 64 | // 64 < buffer size < 512, buffer_size is not a power of 2 for testing |
qpdf/test_driver.cc
| @@ -499,7 +499,7 @@ test_8(QPDF& pdf, char const* arg2) | @@ -499,7 +499,7 @@ test_8(QPDF& pdf, char const* arg2) | ||
| 499 | auto b = p1.getBufferSharedPointer(); | 499 | auto b = p1.getBufferSharedPointer(); |
| 500 | // This is a bogus way to use StreamDataProvider, but it does | 500 | // This is a bogus way to use StreamDataProvider, but it does |
| 501 | // adequately test its functionality. | 501 | // adequately test its functionality. |
| 502 | - Provider* provider = new Provider(b); | 502 | + auto* provider = new Provider(b); |
| 503 | auto p = std::shared_ptr<QPDFObjectHandle::StreamDataProvider>(provider); | 503 | auto p = std::shared_ptr<QPDFObjectHandle::StreamDataProvider>(provider); |
| 504 | qstream.replaceStreamData( | 504 | qstream.replaceStreamData( |
| 505 | p, | 505 | p, |
| @@ -1068,7 +1068,7 @@ test_27(QPDF& pdf, char const* arg2) | @@ -1068,7 +1068,7 @@ test_27(QPDF& pdf, char const* arg2) | ||
| 1068 | pl.writeCStr("new data for stream\n"); | 1068 | pl.writeCStr("new data for stream\n"); |
| 1069 | pl.finish(); | 1069 | pl.finish(); |
| 1070 | auto b = pl.getBufferSharedPointer(); | 1070 | auto b = pl.getBufferSharedPointer(); |
| 1071 | - Provider* provider = new Provider(b); | 1071 | + auto* provider = new Provider(b); |
| 1072 | p1 = decltype(p1)(provider); | 1072 | p1 = decltype(p1)(provider); |
| 1073 | } | 1073 | } |
| 1074 | // Create a stream that uses a provider in empty1 and copy it | 1074 | // Create a stream that uses a provider in empty1 and copy it |
| @@ -1095,7 +1095,7 @@ test_27(QPDF& pdf, char const* arg2) | @@ -1095,7 +1095,7 @@ test_27(QPDF& pdf, char const* arg2) | ||
| 1095 | pl.writeCStr("more data for stream\n"); | 1095 | pl.writeCStr("more data for stream\n"); |
| 1096 | pl.finish(); | 1096 | pl.finish(); |
| 1097 | auto b = pl.getBufferSharedPointer(); | 1097 | auto b = pl.getBufferSharedPointer(); |
| 1098 | - Provider* provider = new Provider(b); | 1098 | + auto* provider = new Provider(b); |
| 1099 | p2 = decltype(p2)(provider); | 1099 | p2 = decltype(p2)(provider); |
| 1100 | } | 1100 | } |
| 1101 | QPDF empty3; | 1101 | QPDF empty3; |
qpdf/test_large_file.cc
| @@ -218,7 +218,7 @@ create_pdf(char const* filename) | @@ -218,7 +218,7 @@ create_pdf(char const* filename) | ||
| 218 | image_dict.replaceKey("/BitsPerComponent", newInteger(8)); | 218 | image_dict.replaceKey("/BitsPerComponent", newInteger(8)); |
| 219 | image_dict.replaceKey("/Width", newInteger(width)); | 219 | image_dict.replaceKey("/Width", newInteger(width)); |
| 220 | image_dict.replaceKey("/Height", newInteger(height)); | 220 | image_dict.replaceKey("/Height", newInteger(height)); |
| 221 | - ImageProvider* p = new ImageProvider(pageno); | 221 | + auto* p = new ImageProvider(pageno); |
| 222 | std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider(p); | 222 | std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider(p); |
| 223 | image.replaceStreamData( | 223 | image.replaceStreamData( |
| 224 | provider, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); | 224 | provider, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); |
qpdf/test_tokenizer.cc
| @@ -190,7 +190,7 @@ process(char const* filename, bool include_ignorable, size_t max_len) | @@ -190,7 +190,7 @@ process(char const* filename, bool include_ignorable, size_t max_len) | ||
| 190 | std::shared_ptr<InputSource> is; | 190 | std::shared_ptr<InputSource> is; |
| 191 | 191 | ||
| 192 | // Tokenize file, skipping streams | 192 | // Tokenize file, skipping streams |
| 193 | - FileInputSource* fis = new FileInputSource(filename); | 193 | + auto* fis = new FileInputSource(filename); |
| 194 | is = std::shared_ptr<InputSource>(fis); | 194 | is = std::shared_ptr<InputSource>(fis); |
| 195 | dump_tokens(is, "FILE", max_len, include_ignorable, true, false); | 195 | dump_tokens(is, "FILE", max_len, include_ignorable, true, false); |
| 196 | 196 | ||
| @@ -203,7 +203,7 @@ process(char const* filename, bool include_ignorable, size_t max_len) | @@ -203,7 +203,7 @@ process(char const* filename, bool include_ignorable, size_t max_len) | ||
| 203 | Pl_Buffer plb("buffer"); | 203 | Pl_Buffer plb("buffer"); |
| 204 | page.pipeContents(&plb); | 204 | page.pipeContents(&plb); |
| 205 | auto content_data = plb.getBufferSharedPointer(); | 205 | auto content_data = plb.getBufferSharedPointer(); |
| 206 | - BufferInputSource* bis = | 206 | + auto* bis = |
| 207 | new BufferInputSource("content data", content_data.get()); | 207 | new BufferInputSource("content data", content_data.get()); |
| 208 | is = std::shared_ptr<InputSource>(bis); | 208 | is = std::shared_ptr<InputSource>(bis); |
| 209 | dump_tokens( | 209 | dump_tokens( |
| @@ -220,7 +220,7 @@ process(char const* filename, bool include_ignorable, size_t max_len) | @@ -220,7 +220,7 @@ process(char const* filename, bool include_ignorable, size_t max_len) | ||
| 220 | if (obj.isStream() && obj.getDict().getKey("/Type").isName() && | 220 | if (obj.isStream() && obj.getDict().getKey("/Type").isName() && |
| 221 | obj.getDict().getKey("/Type").getName() == "/ObjStm") { | 221 | obj.getDict().getKey("/Type").getName() == "/ObjStm") { |
| 222 | std::shared_ptr<Buffer> b = obj.getStreamData(qpdf_dl_specialized); | 222 | std::shared_ptr<Buffer> b = obj.getStreamData(qpdf_dl_specialized); |
| 223 | - BufferInputSource* bis = | 223 | + auto* bis = |
| 224 | new BufferInputSource("object stream data", b.get()); | 224 | new BufferInputSource("object stream data", b.get()); |
| 225 | is = std::shared_ptr<InputSource>(bis); | 225 | is = std::shared_ptr<InputSource>(bis); |
| 226 | dump_tokens( | 226 | dump_tokens( |