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