summaryrefslogtreecommitdiffstats
path: root/qpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2011-08-11 17:56:37 +0200
committerJay Berkenbilt <ejb@ql.org>2011-08-11 17:57:37 +0200
commit76b1659177327a64037bf36d7f3e15a73d86bbed (patch)
tree22623001bb99a6fe33943416877a3d5836b550d8 /qpdf
parent14fe2e6de3ae3b91436ccb4948fca75c29565440 (diff)
downloadqpdf-76b1659177327a64037bf36d7f3e15a73d86bbed.tar.zst
enhance PointerHolder so that it can explicitly be told to use delete [] instead of delete, thus making it useful to run valgrind over qpdf during its test suite
Diffstat (limited to 'qpdf')
-rw-r--r--qpdf/qpdf-ctest.c17
-rw-r--r--qpdf/qpdf.testcov1
-rw-r--r--qpdf/test_driver.cc2
3 files changed, 18 insertions, 2 deletions
diff --git a/qpdf/qpdf-ctest.c b/qpdf/qpdf-ctest.c
index aa61b9a1..ffb1fff8 100644
--- a/qpdf/qpdf-ctest.c
+++ b/qpdf/qpdf-ctest.c
@@ -337,6 +337,10 @@ static void test16(char const* infile,
char const* outfile,
char const* outfile2)
{
+ unsigned long buflen = 0L;
+ unsigned char const* buf = 0;
+ FILE* f = 0;
+
qpdf_read(qpdf, infile, password);
print_info("/Author");
print_info("/Producer");
@@ -347,11 +351,22 @@ static void test16(char const* infile,
print_info("/Author");
print_info("/Producer");
print_info("/Creator");
- qpdf_init_write(qpdf, outfile);
+ qpdf_init_write_memory(qpdf);
qpdf_set_static_ID(qpdf, QPDF_TRUE);
qpdf_set_static_aes_IV(qpdf, QPDF_TRUE);
qpdf_set_stream_data_mode(qpdf, qpdf_s_uncompress);
qpdf_write(qpdf);
+ f = fopen(outfile, "wb");
+ if (f == NULL)
+ {
+ fprintf(stderr, "%s: unable to open %s: %s\n",
+ whoami, outfile, strerror(errno));
+ exit(2);
+ }
+ buflen = qpdf_get_buffer_length(qpdf);
+ buf = qpdf_get_buffer(qpdf);
+ fwrite(buf, 1, buflen, f);
+ fclose(f);
report_errors();
}
diff --git a/qpdf/qpdf.testcov b/qpdf/qpdf.testcov
index 520b7fbe..51a5f6aa 100644
--- a/qpdf/qpdf.testcov
+++ b/qpdf/qpdf.testcov
@@ -199,3 +199,4 @@ qpdf-c set_info_key to value 0
qpdf-c set_info_key to null 0
qpdf-c set-info-key use existing info 0
qpdf-c add info to trailer 0
+qpdf-c called qpdf_init_write_memory 0
diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc
index 89da9144..bc9bdfc9 100644
--- a/qpdf/test_driver.cc
+++ b/qpdf/test_driver.cc
@@ -76,7 +76,7 @@ void runtest(int n, char const* filename)
fseek(f, 0, SEEK_END);
size_t size = (size_t) ftell(f);
fseek(f, 0, SEEK_SET);
- file_buf = new char[size];
+ file_buf = PointerHolder<char>(true, new char[size]);
char* buf_p = file_buf.getPointer();
size_t bytes_read = 0;
size_t len = 0;