Commit 737c190dc6cfff8f2183d6e6815a606265a9cf2e
1 parent
154d60c4
Refactor `QPDFWriter` to use `std::unique_ptr` for `m->to_delete` and `m->buffer_pipeline`.
Showing
1 changed file
with
6 additions
and
8 deletions
libqpdf/QPDFWriter.cc
| ... | ... | @@ -276,7 +276,7 @@ class QPDFWriter::Members |
| 276 | 276 | char const* filename{"unspecified"}; |
| 277 | 277 | FILE* file{nullptr}; |
| 278 | 278 | bool close_file{false}; |
| 279 | - Pl_Buffer* buffer_pipeline{nullptr}; | |
| 279 | + std::unique_ptr<Pl_Buffer> buffer_pipeline{nullptr}; | |
| 280 | 280 | Buffer* output_buffer{nullptr}; |
| 281 | 281 | bool normalize_content_set{false}; |
| 282 | 282 | bool normalize_content{false}; |
| ... | ... | @@ -311,7 +311,7 @@ class QPDFWriter::Members |
| 311 | 311 | std::string extra_header_text; |
| 312 | 312 | int encryption_dict_objid{0}; |
| 313 | 313 | std::string cur_data_key; |
| 314 | - std::list<std::shared_ptr<Pipeline>> to_delete; | |
| 314 | + std::unique_ptr<Pipeline> file_pl; | |
| 315 | 315 | qpdf::pl::Count* pipeline{nullptr}; |
| 316 | 316 | std::vector<QPDFObjectHandle> object_queue; |
| 317 | 317 | size_t object_queue_front{0}; |
| ... | ... | @@ -398,18 +398,16 @@ QPDFWriter::setOutputFile(char const* description, FILE* file, bool close_file) |
| 398 | 398 | m->filename = description; |
| 399 | 399 | m->file = file; |
| 400 | 400 | m->close_file = close_file; |
| 401 | - std::shared_ptr<Pipeline> p = std::make_shared<Pl_StdioFile>("qpdf output", file); | |
| 402 | - m->to_delete.push_back(p); | |
| 403 | - m->pipeline_stack.initialize(p.get()); | |
| 401 | + m->file_pl = std::make_unique<Pl_StdioFile>("qpdf output", file); | |
| 402 | + m->pipeline_stack.initialize(m->file_pl.get()); | |
| 404 | 403 | } |
| 405 | 404 | |
| 406 | 405 | void |
| 407 | 406 | QPDFWriter::setOutputMemory() |
| 408 | 407 | { |
| 409 | 408 | m->filename = "memory buffer"; |
| 410 | - m->buffer_pipeline = new Pl_Buffer("qpdf output"); | |
| 411 | - m->to_delete.push_back(std::shared_ptr<Pipeline>(m->buffer_pipeline)); | |
| 412 | - m->pipeline_stack.initialize(m->buffer_pipeline); | |
| 409 | + m->buffer_pipeline = std::make_unique<Pl_Buffer>("qpdf output"); | |
| 410 | + m->pipeline_stack.initialize(m->buffer_pipeline.get()); | |
| 413 | 411 | } |
| 414 | 412 | |
| 415 | 413 | Buffer* | ... | ... |