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

Rename to qpdf_oh_free_buffer

This commit is contained in:
Chao Li(VISION) 2024-09-20 04:53:32 +00:00
parent 8c1cde4ec3
commit f6ae1ff16a
5 changed files with 13 additions and 8 deletions

View File

@ -1,3 +1,8 @@
2024-09-20 Chao Li <mslichao@outlook.com>
* Add C API qpdf_oh_free_buffer to release memory allocated by
stream data functions
2024-08-06 M Holger <m.holger@qpdf.org>
* Bug fix: when writing real numbers as JSON ensure that they don't

View File

@ -929,11 +929,11 @@ extern "C" {
/* 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_free_buffer
* 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.
*/
QPDF_DLL
void qpdf_free_buffer(unsigned char** bufp);
void qpdf_oh_free_buffer(unsigned char** bufp);
/* The data pointed to by bufp will be copied by the library. It does not need to remain valid
* after the call returns.

View File

@ -1772,9 +1772,9 @@ qpdf_oh_get_page_content_data(qpdf_data qpdf, qpdf_oh page_oh, unsigned char** b
}
void
qpdf_free_buffer(unsigned char** bufp)
qpdf_oh_free_buffer(unsigned char** bufp)
{
QTC::TC("qpdf", "qpdf-c called qpdf_free_buffer");
QTC::TC("qpdf", "qpdf-c called qpdf_oh_free_buffer");
if (bufp && *bufp) {
free(*bufp);
*bufp = nullptr;

View File

@ -1151,7 +1151,7 @@ test38(char const* infile, char const* password, char const* outfile, char const
assert(qpdf_oh_get_stream_data(qpdf, stream, qpdf_dl_none, 0, &buf, &len) == 0);
assert(len == 53);
assert(((int)buf[0] == 'x') && ((int)buf[1] == 0234));
qpdf_free_buffer(&buf);
qpdf_oh_free_buffer(&buf);
/* Test whether filterable */
QPDF_BOOL filtered = QPDF_FALSE;
@ -1169,8 +1169,8 @@ 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_free_buffer(&buf);
qpdf_free_buffer(&buf2);
qpdf_oh_free_buffer(&buf);
qpdf_oh_free_buffer(&buf2);
/* errors */
printf("page content on broken page\n");

View File

@ -626,7 +626,7 @@ qpdf-c stream data filtered set 1
qpdf-c stream data buf set 1
qpdf-c called qpdf_oh_get_page_content_data 0
qpdf-c called qpdf_oh_replace_stream_data 0
qpdf-c called qpdf_free_buffer 0
qpdf-c called qpdf_oh_free_buffer 0
qpdf-c silence oh errors 0
qpdf-c called qpdf_oh_get_binary_string_value 0
qpdf-c called qpdf_oh_get_binary_utf8_value 0