aboutsummaryrefslogtreecommitdiffstats
path: root/libtests
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-04-09 20:49:10 +0200
committerJay Berkenbilt <ejb@ql.org>2022-04-09 23:33:29 +0200
commitba0ef7a124e9aecc2d0113598c851bae4710b887 (patch)
tree5dec35b3d51effc43e55ff3ba0b1ca3f274eea17 /libtests
parenta68703b07e928be0eeb909c0e777e13e88cbf86d (diff)
downloadqpdf-ba0ef7a124e9aecc2d0113598c851bae4710b887.tar.zst
Replace PointerHolder with std::shared_ptr in the rest of the code
Increase to POINTERHOLDER_TRANSITION=3 patrepl s/PointerHolder/std::shared_ptr/g **/*.cc **/*.hh patrepl s/make_pointer_holder/std::make_shared/g **/*.cc patrepl s/make_array_pointer_holder/QUtil::make_shared_array/g **/*.cc patrepl s,qpdf/std::shared_ptr,qpdf/PointerHolder, **/*.cc **/*.hh git restore include/qpdf/PointerHolder.hh git restore libtests/pointer_holder.cc cleanpatch ./format-code
Diffstat (limited to 'libtests')
-rw-r--r--libtests/input_source.cc12
-rw-r--r--libtests/json_parse.cc2
-rw-r--r--libtests/qutil.cc4
3 files changed, 9 insertions, 9 deletions
diff --git a/libtests/input_source.cc b/libtests/input_source.cc
index cb62daea..a32428be 100644
--- a/libtests/input_source.cc
+++ b/libtests/input_source.cc
@@ -5,11 +5,11 @@
#include <cstring>
#include <iostream>
-static PointerHolder<Buffer>
+static std::shared_ptr<Buffer>
get_buffer()
{
size_t size = 3172;
- PointerHolder<Buffer> b(new Buffer(size));
+ std::shared_ptr<Buffer> b(new Buffer(size));
unsigned char* p = b->getBuffer();
for (size_t i = 0; i < size; ++i) {
p[i] = static_cast<unsigned char>(i & 0xff);
@@ -20,7 +20,7 @@ get_buffer()
class Finder: public InputSource::Finder
{
public:
- Finder(PointerHolder<InputSource> is, std::string const& after) :
+ Finder(std::shared_ptr<InputSource> is, std::string const& after) :
is(is),
after(after)
{
@@ -31,7 +31,7 @@ class Finder: public InputSource::Finder
virtual bool check();
private:
- PointerHolder<InputSource> is;
+ std::shared_ptr<InputSource> is;
std::string after;
};
@@ -57,14 +57,14 @@ check(char const* description, bool expected, bool actual)
int
main()
{
- PointerHolder<Buffer> b1 = get_buffer();
+ std::shared_ptr<Buffer> b1 = get_buffer();
unsigned char* b = b1->getBuffer();
// Straddle block boundaries
memcpy(b + 1022, "potato", 6);
// Overlap so that the first check() would advance past the start
// of the next match
memcpy(b + 2037, "potato potato salad ", 20);
- auto is = PointerHolder<InputSource>(
+ auto is = std::shared_ptr<InputSource>(
new BufferInputSource("test buffer input source", b1.get()));
Finder f1(is, "salad");
check("find potato salad", true, is->findFirst("potato", 0, 0, f1));
diff --git a/libtests/json_parse.cc b/libtests/json_parse.cc
index 13d29b65..77692eab 100644
--- a/libtests/json_parse.cc
+++ b/libtests/json_parse.cc
@@ -11,7 +11,7 @@ main(int argc, char* argv[])
}
char const* filename = argv[1];
try {
- PointerHolder<char> buf;
+ std::shared_ptr<char> buf;
size_t size;
QUtil::read_file_into_memory(filename, buf, size);
std::string s(buf.get(), size);
diff --git a/libtests/qutil.cc b/libtests/qutil.cc
index fea9fca1..dda49898 100644
--- a/libtests/qutil.cc
+++ b/libtests/qutil.cc
@@ -529,7 +529,7 @@ read_from_file_test()
fclose(fp);
}
- PointerHolder<char> buf;
+ std::shared_ptr<char> buf;
size_t size = 0;
QUtil::read_file_into_memory("other-file", buf, size);
std::cout << "read " << size << " bytes" << std::endl;
@@ -595,7 +595,7 @@ assert_no_file(char const* filename)
void
rename_delete_test()
{
- PointerHolder<char> buf;
+ std::shared_ptr<char> buf;
size_t size = 0;
try {