aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-02-07 14:02:16 +0100
committerJay Berkenbilt <ejb@ql.org>2022-02-07 20:08:46 +0100
commitdf2f5c6a360bd7512d2280aa9cb582bc0aa622bd (patch)
treef7a036ddeee36a172e1903056e7f4ed49a323efd /include
parentcfaae47dc6704a54e3e84decbfbe8840c33f2fc4 (diff)
downloadqpdf-df2f5c6a360bd7512d2280aa9cb582bc0aa622bd.tar.zst
Add QUtil::make_shared_array to help with PointerHolder transition
Diffstat (limited to 'include')
-rw-r--r--include/qpdf/QUtil.hh9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/qpdf/QUtil.hh b/include/qpdf/QUtil.hh
index 927fc1d8..b4cb1f6a 100644
--- a/include/qpdf/QUtil.hh
+++ b/include/qpdf/QUtil.hh
@@ -165,6 +165,15 @@ namespace QUtil
QPDF_DLL
std::unique_ptr<char[]> make_unique_cstr(std::string const&);
+ // Create a shared pointer to an array. From c++20,
+ // std::make_shared<T[]>(n) does this.
+ template <typename T>
+ std::shared_ptr<T>
+ make_shared_array(size_t n)
+ {
+ return std::shared_ptr<T>(new T[n], std::default_delete<T[]>());
+ }
+
// Returns lower-case hex-encoded version of the string, treating
// each character in the input string as unsigned. The output
// string will be twice as long as the input string.