[poppler] poppler/UTF.cc poppler/UTF.h

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Feb 10 10:37:19 UTC 2022


 poppler/UTF.cc |    4 ++--
 poppler/UTF.h  |    3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

New commits:
commit 838e5ecf576b41323f657cdc5f8779bcc7d843c8
Author: Albert Astals Cid <aacid at kde.org>
Date:   Thu Feb 10 11:32:34 2022 +0100

    Make utf8ToUtf16WithBom return a unique_ptr

diff --git a/poppler/UTF.cc b/poppler/UTF.cc
index 8dd972c7..bfb23f9d 100644
--- a/poppler/UTF.cc
+++ b/poppler/UTF.cc
@@ -357,9 +357,9 @@ uint16_t *utf8ToUtf16(const char *utf8, int *len)
     return utf16;
 }
 
-GooString *utf8ToUtf16WithBom(const std::string &utf8)
+std::unique_ptr<GooString> utf8ToUtf16WithBom(const std::string &utf8)
 {
-    GooString *result = new GooString();
+    auto result = std::make_unique<GooString>();
     if (utf8.empty()) {
         return result;
     }
diff --git a/poppler/UTF.h b/poppler/UTF.h
index 5dca83e4..8b541450 100644
--- a/poppler/UTF.h
+++ b/poppler/UTF.h
@@ -18,6 +18,7 @@
 
 #include <cstdint>
 #include <climits>
+#include <memory>
 
 #include "goo/GooString.h"
 #include "CharTypes.h"
@@ -76,7 +77,7 @@ uint16_t POPPLER_PRIVATE_EXPORT *utf8ToUtf16(const char *utf8, int *len = nullpt
 // The caller owns the returned pointer.
 //  utf8 - UTF-8 string to convert. An empty string is acceptable.
 // Returns a big endian UTF-16 string with BOM or an empty string without BOM.
-GooString POPPLER_PRIVATE_EXPORT *utf8ToUtf16WithBom(const std::string &utf8);
+std::unique_ptr<GooString> POPPLER_PRIVATE_EXPORT utf8ToUtf16WithBom(const std::string &utf8);
 
 // Count number of UTF-8 bytes required to convert a UTF-16 string to
 // UTF-8 (excluding terminating NULL).


More information about the poppler mailing list