Commit 54afdecbae6ec247e12203d4046a1bd752566583
1 parent
b0ceea46
Refactor code to use modern C++ practices for clarity.
Replaced raw pointer defaults (e.g., `0`) with `nullptr` for better readability and type-safety. Simplified object initializer syntax using uniform initialization `{}`. These changes enhance code maintainability and ensure modern C++ standards compliance.
Showing
5 changed files
with
6 additions
and
5 deletions
libqpdf/QPDFWriter.cc
| @@ -2285,7 +2285,7 @@ QPDFWriter::write() | @@ -2285,7 +2285,7 @@ QPDFWriter::write() | ||
| 2285 | QPDFObjGen | 2285 | QPDFObjGen |
| 2286 | QPDFWriter::getRenumberedObjGen(QPDFObjGen og) | 2286 | QPDFWriter::getRenumberedObjGen(QPDFObjGen og) |
| 2287 | { | 2287 | { |
| 2288 | - return QPDFObjGen(m->obj[og].renumber, 0); | 2288 | + return {m->obj[og].renumber, 0}; |
| 2289 | } | 2289 | } |
| 2290 | 2290 | ||
| 2291 | std::map<QPDFObjGen, QPDFXRefEntry> | 2291 | std::map<QPDFObjGen, QPDFXRefEntry> |
libqpdf/QPDF_objects.cc
| @@ -1807,7 +1807,7 @@ QPDF::nextObjGen() | @@ -1807,7 +1807,7 @@ QPDF::nextObjGen() | ||
| 1807 | if (max_objid == std::numeric_limits<int>::max()) { | 1807 | if (max_objid == std::numeric_limits<int>::max()) { |
| 1808 | throw std::range_error("max object id is too high to create new objects"); | 1808 | throw std::range_error("max object id is too high to create new objects"); |
| 1809 | } | 1809 | } |
| 1810 | - return QPDFObjGen(max_objid + 1, 0); | 1810 | + return {max_objid + 1, 0}; |
| 1811 | } | 1811 | } |
| 1812 | 1812 | ||
| 1813 | QPDFObjectHandle | 1813 | QPDFObjectHandle |
libqpdf/qpdf/QPDFCrypto_native.hh
| @@ -23,7 +23,8 @@ class QPDFCrypto_native final: public QPDFCryptoImpl | @@ -23,7 +23,8 @@ class QPDFCrypto_native final: public QPDFCryptoImpl | ||
| 23 | void MD5_digest(MD5_Digest) final; | 23 | void MD5_digest(MD5_Digest) final; |
| 24 | 24 | ||
| 25 | void RC4_init(unsigned char const* key_data, int key_len = -1) final; | 25 | void RC4_init(unsigned char const* key_data, int key_len = -1) final; |
| 26 | - void RC4_process(unsigned char const* in_data, size_t len, unsigned char* out_data = 0) final; | 26 | + void |
| 27 | + RC4_process(unsigned char const* in_data, size_t len, unsigned char* out_data = nullptr) final; | ||
| 27 | void RC4_finalize() final; | 28 | void RC4_finalize() final; |
| 28 | 29 | ||
| 29 | void SHA2_init(int bits) final; | 30 | void SHA2_init(int bits) final; |
libqpdf/qpdf/RC4_native.hh
| @@ -10,7 +10,7 @@ class RC4_native | @@ -10,7 +10,7 @@ class RC4_native | ||
| 10 | RC4_native(unsigned char const* key_data, int key_len = -1); | 10 | RC4_native(unsigned char const* key_data, int key_len = -1); |
| 11 | 11 | ||
| 12 | // out_data = 0 means to encrypt/decrypt in place | 12 | // out_data = 0 means to encrypt/decrypt in place |
| 13 | - void process(unsigned char const* in_data, size_t len, unsigned char* out_data = 0); | 13 | + void process(unsigned char const* in_data, size_t len, unsigned char* out_data = nullptr); |
| 14 | 14 | ||
| 15 | private: | 15 | private: |
| 16 | class RC4Key | 16 | class RC4Key |
libtests/crypto_provider.cc
| @@ -47,7 +47,7 @@ class Potato: public QPDFCryptoImpl | @@ -47,7 +47,7 @@ class Potato: public QPDFCryptoImpl | ||
| 47 | std::string | 47 | std::string |
| 48 | SHA2_digest() override | 48 | SHA2_digest() override |
| 49 | { | 49 | { |
| 50 | - return std::string(); | 50 | + return {}; |
| 51 | } | 51 | } |
| 52 | void | 52 | void |
| 53 | RC4_init(const unsigned char* key_data, int key_len) override | 53 | RC4_init(const unsigned char* key_data, int key_len) override |