Commit f6ae1ff16a2b874b8c536c6c797986513a39134d

Authored by Chao Li(VISION)
1 parent 8c1cde4e

Rename to qpdf_oh_free_buffer

ChangeLog
  1 +2024-09-20 Chao Li <mslichao@outlook.com>
  2 +
  3 + * Add C API qpdf_oh_free_buffer to release memory allocated by
  4 + stream data functions
  5 +
1 2024-08-06 M Holger <m.holger@qpdf.org> 6 2024-08-06 M Holger <m.holger@qpdf.org>
2 7
3 * Bug fix: when writing real numbers as JSON ensure that they don't 8 * Bug fix: when writing real numbers as JSON ensure that they don't
include/qpdf/qpdf-c.h
@@ -929,11 +929,11 @@ extern &quot;C&quot; { @@ -929,11 +929,11 @@ extern &quot;C&quot; {
929 929
930 /* Call free to release the buffer allocated with malloc. This function can be used to free 930 /* Call free to release the buffer allocated with malloc. This function can be used to free
931 * buffers that were dynamically allocated by qpdf functions such as qpdf_oh_get_stream_data 931 * buffers that were dynamically allocated by qpdf functions such as qpdf_oh_get_stream_data
932 - * or qpdf_oh_get_page_content_data. The caller is responsible for calling qpdf_free_buffer 932 + * or qpdf_oh_get_page_content_data. The caller is responsible for calling qpdf_oh_free_buffer
933 * to manage memory properly and avoid memory leaks. 933 * to manage memory properly and avoid memory leaks.
934 */ 934 */
935 QPDF_DLL 935 QPDF_DLL
936 - void qpdf_free_buffer(unsigned char** bufp); 936 + void qpdf_oh_free_buffer(unsigned char** bufp);
937 937
938 /* The data pointed to by bufp will be copied by the library. It does not need to remain valid 938 /* The data pointed to by bufp will be copied by the library. It does not need to remain valid
939 * after the call returns. 939 * after the call returns.
libqpdf/qpdf-c.cc
@@ -1772,9 +1772,9 @@ qpdf_oh_get_page_content_data(qpdf_data qpdf, qpdf_oh page_oh, unsigned char** b @@ -1772,9 +1772,9 @@ qpdf_oh_get_page_content_data(qpdf_data qpdf, qpdf_oh page_oh, unsigned char** b
1772 } 1772 }
1773 1773
1774 void 1774 void
1775 -qpdf_free_buffer(unsigned char** bufp) 1775 +qpdf_oh_free_buffer(unsigned char** bufp)
1776 { 1776 {
1777 - QTC::TC("qpdf", "qpdf-c called qpdf_free_buffer"); 1777 + QTC::TC("qpdf", "qpdf-c called qpdf_oh_free_buffer");
1778 if (bufp && *bufp) { 1778 if (bufp && *bufp) {
1779 free(*bufp); 1779 free(*bufp);
1780 *bufp = nullptr; 1780 *bufp = nullptr;
qpdf/qpdf-ctest.c
@@ -1151,7 +1151,7 @@ test38(char const* infile, char const* password, char const* outfile, char const @@ -1151,7 +1151,7 @@ test38(char const* infile, char const* password, char const* outfile, char const
1151 assert(qpdf_oh_get_stream_data(qpdf, stream, qpdf_dl_none, 0, &buf, &len) == 0); 1151 assert(qpdf_oh_get_stream_data(qpdf, stream, qpdf_dl_none, 0, &buf, &len) == 0);
1152 assert(len == 53); 1152 assert(len == 53);
1153 assert(((int)buf[0] == 'x') && ((int)buf[1] == 0234)); 1153 assert(((int)buf[0] == 'x') && ((int)buf[1] == 0234));
1154 - qpdf_free_buffer(&buf); 1154 + qpdf_oh_free_buffer(&buf);
1155 1155
1156 /* Test whether filterable */ 1156 /* Test whether filterable */
1157 QPDF_BOOL filtered = QPDF_FALSE; 1157 QPDF_BOOL filtered = QPDF_FALSE;
@@ -1169,8 +1169,8 @@ test38(char const* infile, char const* password, char const* outfile, char const @@ -1169,8 +1169,8 @@ test38(char const* infile, char const* password, char const* outfile, char const
1169 assert(qpdf_oh_get_page_content_data(qpdf, page2, &buf2, &len) == 0); 1169 assert(qpdf_oh_get_page_content_data(qpdf, page2, &buf2, &len) == 0);
1170 assert(len == 47); 1170 assert(len == 47);
1171 assert(memcmp(buf, buf2, len) == 0); 1171 assert(memcmp(buf, buf2, len) == 0);
1172 - qpdf_free_buffer(&buf);  
1173 - qpdf_free_buffer(&buf2); 1172 + qpdf_oh_free_buffer(&buf);
  1173 + qpdf_oh_free_buffer(&buf2);
1174 1174
1175 /* errors */ 1175 /* errors */
1176 printf("page content on broken page\n"); 1176 printf("page content on broken page\n");
qpdf/qpdf.testcov
@@ -626,7 +626,7 @@ qpdf-c stream data filtered set 1 @@ -626,7 +626,7 @@ qpdf-c stream data filtered set 1
626 qpdf-c stream data buf set 1 626 qpdf-c stream data buf set 1
627 qpdf-c called qpdf_oh_get_page_content_data 0 627 qpdf-c called qpdf_oh_get_page_content_data 0
628 qpdf-c called qpdf_oh_replace_stream_data 0 628 qpdf-c called qpdf_oh_replace_stream_data 0
629 -qpdf-c called qpdf_free_buffer 0 629 +qpdf-c called qpdf_oh_free_buffer 0
630 qpdf-c silence oh errors 0 630 qpdf-c silence oh errors 0
631 qpdf-c called qpdf_oh_get_binary_string_value 0 631 qpdf-c called qpdf_oh_get_binary_string_value 0
632 qpdf-c called qpdf_oh_get_binary_utf8_value 0 632 qpdf-c called qpdf_oh_get_binary_utf8_value 0