2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-21 10:29:08 +00:00

Tweak #1287 comments

This commit is contained in:
m-holger 2024-09-27 11:58:46 +01:00
parent 638bf5f9ae
commit 43a88e1d28
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 */