[Libreoffice-commits] core.git: connectivity/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Sep 6 06:33:21 UTC 2018


 connectivity/source/drivers/odbc/OResultSetMetaData.cxx |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

New commits:
commit 16afac775a048d6d57d43952c855345f47cb231f
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Sep 5 15:56:31 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Sep 6 08:32:55 2018 +0200

    loplugin:useuniqueptr in OResultSetMetaData
    
    Change-Id: I74a12381a222fb3b394176db41cb9d6a9091d5a3
    Reviewed-on: https://gerrit.libreoffice.org/60052
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/connectivity/source/drivers/odbc/OResultSetMetaData.cxx b/connectivity/source/drivers/odbc/OResultSetMetaData.cxx
index fcf4ce65374d..6eb19d6b945f 100644
--- a/connectivity/source/drivers/odbc/OResultSetMetaData.cxx
+++ b/connectivity/source/drivers/odbc/OResultSetMetaData.cxx
@@ -37,12 +37,12 @@ OUString OResultSetMetaData::getCharColAttrib(sal_Int32 _column,sal_Int32 ident)
         column = m_vMapping[_column];
 
     SQLSMALLINT BUFFER_LEN = 128;
-    char *pName = new char[BUFFER_LEN+1];
+    std::unique_ptr<char[]> pName(new char[BUFFER_LEN+1]);
     SQLSMALLINT nRealLen=0;
     SQLRETURN nRet = N3SQLColAttribute(m_aStatementHandle,
                                     static_cast<SQLUSMALLINT>(column),
                                     static_cast<SQLUSMALLINT>(ident),
-                                    static_cast<SQLPOINTER>(pName),
+                                    static_cast<SQLPOINTER>(pName.get()),
                                     BUFFER_LEN,
                                     &nRealLen,
                                     nullptr
@@ -52,24 +52,23 @@ OUString OResultSetMetaData::getCharColAttrib(sal_Int32 _column,sal_Int32 ident)
     {
         if ( nRealLen < 0 )
             nRealLen = BUFFER_LEN;
-        sValue = OUString(pName,nRealLen,m_pConnection->getTextEncoding());
+        sValue = OUString(pName.get(),nRealLen,m_pConnection->getTextEncoding());
     }
-    delete [] pName;
+    pName.reset();
     OTools::ThrowException(m_pConnection,nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     if(nRealLen > BUFFER_LEN)
     {
-        pName = new char[nRealLen+1];
+        pName.reset(new char[nRealLen+1]);
         nRet = N3SQLColAttribute(m_aStatementHandle,
                                     static_cast<SQLUSMALLINT>(column),
                                     static_cast<SQLUSMALLINT>(ident),
-                                    static_cast<SQLPOINTER>(pName),
+                                    static_cast<SQLPOINTER>(pName.get()),
                                     nRealLen,
                                     &nRealLen,
                                     nullptr
                                     );
         if ( nRet == SQL_SUCCESS && nRealLen > 0)
-            sValue = OUString(pName,nRealLen,m_pConnection->getTextEncoding());
-        delete [] pName;
+            sValue = OUString(pName.get(),nRealLen,m_pConnection->getTextEncoding());
         OTools::ThrowException(m_pConnection,nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     }
 


More information about the Libreoffice-commits mailing list