Commit fc656816c142c22f43094d16de99559bfbf0fa2f
Committed by
GitHub
Merge pull request #1025 from zclifford/main
Remove use of non-standard `char_traits<unsigned char>` from Pl_Buffer
Showing
2 changed files
with
5 additions
and
4 deletions
include/qpdf/Pl_Buffer.hh
| ... | ... | @@ -33,6 +33,7 @@ |
| 33 | 33 | #include <qpdf/PointerHolder.hh> // unused -- remove in qpdf 12 (see #785) |
| 34 | 34 | |
| 35 | 35 | #include <memory> |
| 36 | +#include <vector> | |
| 36 | 37 | |
| 37 | 38 | class QPDF_DLL_CLASS Pl_Buffer: public Pipeline |
| 38 | 39 | { |
| ... | ... | @@ -77,7 +78,7 @@ class QPDF_DLL_CLASS Pl_Buffer: public Pipeline |
| 77 | 78 | Members(Members const&) = delete; |
| 78 | 79 | |
| 79 | 80 | bool ready{true}; |
| 80 | - std::basic_string<unsigned char> data; | |
| 81 | + std::vector<unsigned char> data; | |
| 81 | 82 | }; |
| 82 | 83 | |
| 83 | 84 | std::shared_ptr<Members> m; | ... | ... |
libqpdf/Pl_Buffer.cc
| ... | ... | @@ -19,7 +19,7 @@ Pl_Buffer::~Pl_Buffer() // NOLINT (modernize-use-equals-default) |
| 19 | 19 | void |
| 20 | 20 | Pl_Buffer::write(unsigned char const* buf, size_t len) |
| 21 | 21 | { |
| 22 | - m->data.append(buf, len); | |
| 22 | + m->data.insert(m->data.end(), buf, buf + len); | |
| 23 | 23 | m->ready = false; |
| 24 | 24 | |
| 25 | 25 | if (getNext(true)) { |
| ... | ... | @@ -43,7 +43,7 @@ Pl_Buffer::getBuffer() |
| 43 | 43 | throw std::logic_error("Pl_Buffer::getBuffer() called when not ready"); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - auto size = m->data.length(); | |
| 46 | + auto size = m->data.size(); | |
| 47 | 47 | auto* b = new Buffer(size); |
| 48 | 48 | if (size > 0) { |
| 49 | 49 | unsigned char* p = b->getBuffer(); |
| ... | ... | @@ -65,7 +65,7 @@ Pl_Buffer::getMallocBuffer(unsigned char** buf, size_t* len) |
| 65 | 65 | if (!m->ready) { |
| 66 | 66 | throw std::logic_error("Pl_Buffer::getMallocBuffer() called when not ready"); |
| 67 | 67 | } |
| 68 | - auto size = m->data.length(); | |
| 68 | + auto size = m->data.size(); | |
| 69 | 69 | *len = size; |
| 70 | 70 | if (size > 0) { |
| 71 | 71 | *buf = reinterpret_cast<unsigned char*>(malloc(size)); | ... | ... |