2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-11-16 09:37:08 +00:00

Merge pull request #1293 from m-holger/pr1287

Tweak #1287 comments
This commit is contained in:
m-holger 2024-09-27 12:26:30 +01:00 committed by GitHub
commit 529501aa41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 7 deletions

View File

@ -1,7 +1,7 @@
2024-09-20 Chao Li <mslichao@outlook.com>
* Add C API qpdf_oh_free_buffer to release memory allocated by
stream data functions.
* Add C API function qpdf_oh_free_buffer to release memory allocated
by stream data functions.
2024-08-25 M Holger <m.holger@qpdf.org>

View File

@ -927,10 +927,11 @@ extern "C" {
QPDF_ERROR_CODE qpdf_oh_get_page_content_data(
qpdf_data qpdf, qpdf_oh page_oh, unsigned char** bufp, size_t* len);
/* Call free to release the buffer allocated with malloc. This function can be used to free
* buffers that were dynamically allocated by qpdf functions such as qpdf_oh_get_stream_data
* or qpdf_oh_get_page_content_data. The caller is responsible for calling qpdf_oh_free_buffer
* to manage memory properly and avoid memory leaks.
/* Call free to release a buffer allocated with malloc. This function can be used to free
* buffers that were dynamically allocated by qpdf functions such as qpdf_oh_get_stream_data or
* qpdf_oh_get_page_content_data. The caller is responsible for calling qpdf_oh_free_buffer (or
* calling free directly) to manage memory properly and avoid memory leaks. This function has no
* equivalent in the C++ API.
*/
QPDF_DLL
void qpdf_oh_free_buffer(unsigned char** bufp);

View File

@ -1152,6 +1152,7 @@ test38(char const* infile, char const* password, char const* outfile, char const
assert(len == 53);
assert(((int)buf[0] == 'x') && ((int)buf[1] == 0234));
qpdf_oh_free_buffer(&buf);
assert(!buf);
/* Test whether filterable */
QPDF_BOOL filtered = QPDF_FALSE;
@ -1169,7 +1170,7 @@ test38(char const* infile, char const* password, char const* outfile, char const
assert(qpdf_oh_get_page_content_data(qpdf, page2, &buf2, &len) == 0);
assert(len == 47);
assert(memcmp(buf, buf2, len) == 0);
qpdf_oh_free_buffer(&buf);
free(buf);
qpdf_oh_free_buffer(&buf2);
/* errors */