Commit 8cf7f2bfb542b1583aa525611179d1a545f945d5
1 parent
5f3f7882
API contract: qpdf_get_qpdf_version() returns a static
Showing
5 changed files
with
12 additions
and
3 deletions
ChangeLog
| 1 | 1 | 2022-02-05 Jay Berkenbilt <ejb@ql.org> |
| 2 | 2 | |
| 3 | + * Add comments letting people know that the version string | |
| 4 | + returned by QPDF::QPDFVersion and qpdf_get_qpdf_version is static. | |
| 5 | + | |
| 3 | 6 | * Add QUtil::make_unique_cstr to return a std::unique_ptr<char[]> |
| 4 | 7 | as an alternative to QUtil::copy_string and |
| 5 | 8 | QUtil::make_shared_cstr. | ... | ... |
include/qpdf/QPDF.hh
include/qpdf/qpdf-c.h
| ... | ... | @@ -171,7 +171,9 @@ extern "C" { |
| 171 | 171 | QPDF_DLL |
| 172 | 172 | void qpdf_silence_errors(qpdf_data qpdf); |
| 173 | 173 | |
| 174 | - /* Returns the version of the qpdf software */ | |
| 174 | + /* Returns the version of the qpdf software. This is guaranteed to | |
| 175 | + * be a static value. | |
| 176 | + */ | |
| 175 | 177 | QPDF_DLL |
| 176 | 178 | char const* qpdf_get_qpdf_version(); |
| 177 | 179 | ... | ... |
libqpdf/QPDF.cc
| ... | ... | @@ -26,7 +26,9 @@ |
| 26 | 26 | #include <qpdf/QPDF_Stream.hh> |
| 27 | 27 | #include <qpdf/QPDF_Array.hh> |
| 28 | 28 | |
| 29 | -std::string QPDF::qpdf_version(QPDF_VERSION); | |
| 29 | +// This must be a fixed value. This API returns a const reference to | |
| 30 | +// it, and the C API relies on its being static as well. | |
| 31 | +std::string const QPDF::qpdf_version(QPDF_VERSION); | |
| 30 | 32 | |
| 31 | 33 | static char const* EMPTY_PDF = |
| 32 | 34 | "%PDF-1.3\n" |
| ... | ... | @@ -178,6 +180,7 @@ QPDF::StringDecrypter::decryptString(std::string& val) |
| 178 | 180 | std::string const& |
| 179 | 181 | QPDF::QPDFVersion() |
| 180 | 182 | { |
| 183 | + // The C API relies on this being a static value. | |
| 181 | 184 | return QPDF::qpdf_version; |
| 182 | 185 | } |
| 183 | 186 | ... | ... |
libqpdf/qpdf-c.cc
| ... | ... | @@ -161,6 +161,7 @@ static QPDF_ERROR_CODE trap_errors( |
| 161 | 161 | char const* qpdf_get_qpdf_version() |
| 162 | 162 | { |
| 163 | 163 | QTC::TC("qpdf", "qpdf-c called qpdf_get_qpdf_version"); |
| 164 | + // The API guarantees that this is a static value. | |
| 164 | 165 | return QPDF::QPDFVersion().c_str(); |
| 165 | 166 | } |
| 166 | 167 | ... | ... |