emfio/source/reader/emfreader.cxx |    6 +++---
 emfio/source/reader/wmfreader.cxx |    6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

New commits:
commit 1fd620d06d851808dc4d8dce066387b96bf43c9a
Author:     Hossein <hoss...@libreoffice.org>
AuthorDate: Mon Oct 18 21:16:28 2021 +0200
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Mon Oct 25 09:08:37 2021 +0200

    Replacing std::unique_ptr<char[]>
    
    * Replacing std::unique_ptr<char[]> with std::vector<char>
      * The data bytes are read into the vector internal storage
      * Modification of the internal storage of the vector using the
        pointer returned by data() is allowed by the standard
        C++ Standard, revision n4830, section 2.3.11.4 Data [vector.data]
         Returns: A pointer such that [data(), data() + size()) is a valid
           range. For a non-emptyvector, data() == addressof(front()).
         https://github.com/cplusplus/draft/blob/main/papers/n4835.pdf
      * It could be replaced with std::string when data is not modified
          Example: 6c13e5a92ed4b6a10458cd5d5741ddb3d816df4e
      * std::vector<char> is useful when working with C functions that
        get "char *" for writing data. In this case, std::string is not
        usable, because data() method for it returns "const char *".
    
    Change-Id: Ife6013b16a1803c3ad7b0c64aa0cb4c8cf4373ed
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123764
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/emfio/source/reader/emfreader.cxx 
b/emfio/source/reader/emfreader.cxx
index 66b281a09d33..f3b114a57c01 100644
--- a/emfio/source/reader/emfreader.cxx
+++ b/emfio/source/reader/emfreader.cxx
@@ -1923,9 +1923,9 @@ namespace emfio
                                 {
                                     if ( nLen <= ( mnEndPos - 
mpInputStream->Tell() ) )
                                     {
-                                        std::unique_ptr<char[]> pBuf(new char[ 
nLen ]);
-                                        mpInputStream->ReadBytes(pBuf.get(), 
nLen);
-                                        aText = OUString(pBuf.get(), nLen, 
GetCharSet());
+                                        std::vector<char> pBuf( nLen );
+                                        mpInputStream->ReadBytes(pBuf.data(), 
nLen);
+                                        aText = OUString(pBuf.data(), nLen, 
GetCharSet());
                                     }
                                 }
                                 else
diff --git a/emfio/source/reader/wmfreader.cxx 
b/emfio/source/reader/wmfreader.cxx
index bcee84cd386d..62c5168a6bf0 100644
--- a/emfio/source/reader/wmfreader.cxx
+++ b/emfio/source/reader/wmfreader.cxx
@@ -708,9 +708,9 @@ namespace emfio
                         nOriginalTextLen = nOriginalBlockLen = nRemainingSize;
                     }
 
-                    std::unique_ptr<char[]> pChar(new char[nOriginalBlockLen]);
-                    mpInputStream->ReadBytes(pChar.get(), nOriginalBlockLen);
-                    OUString aText(pChar.get(), nOriginalTextLen, 
GetCharSet()); // after this conversion the text may contain
+                    std::vector<char> pChar(nOriginalBlockLen);
+                    mpInputStream->ReadBytes(pChar.data(), nOriginalBlockLen);
+                    OUString aText(pChar.data(), nOriginalTextLen, 
GetCharSet()); // after this conversion the text may contain
                     sal_Int32 nNewTextLen = aText.getLength();                 
        // less character (japanese version), so the
                                                                                
        // dxAry will not fit
                     if ( nNewTextLen )

Reply via email to