From ba0ef7a124e9aecc2d0113598c851bae4710b887 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 9 Apr 2022 14:49:10 -0400 Subject: 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 --- libtests/input_source.cc | 12 ++++++------ libtests/json_parse.cc | 2 +- libtests/qutil.cc | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'libtests') 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 #include -static PointerHolder +static std::shared_ptr get_buffer() { size_t size = 3172; - PointerHolder b(new Buffer(size)); + std::shared_ptr b(new Buffer(size)); unsigned char* p = b->getBuffer(); for (size_t i = 0; i < size; ++i) { p[i] = static_cast(i & 0xff); @@ -20,7 +20,7 @@ get_buffer() class Finder: public InputSource::Finder { public: - Finder(PointerHolder is, std::string const& after) : + Finder(std::shared_ptr is, std::string const& after) : is(is), after(after) { @@ -31,7 +31,7 @@ class Finder: public InputSource::Finder virtual bool check(); private: - PointerHolder is; + std::shared_ptr is; std::string after; }; @@ -57,14 +57,14 @@ check(char const* description, bool expected, bool actual) int main() { - PointerHolder b1 = get_buffer(); + std::shared_ptr 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( + auto is = std::shared_ptr( 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 buf; + std::shared_ptr 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 buf; + std::shared_ptr 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 buf; + std::shared_ptr buf; size_t size = 0; try { -- cgit v1.2.3-54-g00ecf