Kaydet (Commit) 16afac77 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in OResultSetMetaData

Change-Id: I74a12381a222fb3b394176db41cb9d6a9091d5a3
Reviewed-on: https://gerrit.libreoffice.org/60052
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 37d93222
...@@ -37,12 +37,12 @@ OUString OResultSetMetaData::getCharColAttrib(sal_Int32 _column,sal_Int32 ident) ...@@ -37,12 +37,12 @@ OUString OResultSetMetaData::getCharColAttrib(sal_Int32 _column,sal_Int32 ident)
column = m_vMapping[_column]; column = m_vMapping[_column];
SQLSMALLINT BUFFER_LEN = 128; SQLSMALLINT BUFFER_LEN = 128;
char *pName = new char[BUFFER_LEN+1]; std::unique_ptr<char[]> pName(new char[BUFFER_LEN+1]);
SQLSMALLINT nRealLen=0; SQLSMALLINT nRealLen=0;
SQLRETURN nRet = N3SQLColAttribute(m_aStatementHandle, SQLRETURN nRet = N3SQLColAttribute(m_aStatementHandle,
static_cast<SQLUSMALLINT>(column), static_cast<SQLUSMALLINT>(column),
static_cast<SQLUSMALLINT>(ident), static_cast<SQLUSMALLINT>(ident),
static_cast<SQLPOINTER>(pName), static_cast<SQLPOINTER>(pName.get()),
BUFFER_LEN, BUFFER_LEN,
&nRealLen, &nRealLen,
nullptr nullptr
...@@ -52,24 +52,23 @@ OUString OResultSetMetaData::getCharColAttrib(sal_Int32 _column,sal_Int32 ident) ...@@ -52,24 +52,23 @@ OUString OResultSetMetaData::getCharColAttrib(sal_Int32 _column,sal_Int32 ident)
{ {
if ( nRealLen < 0 ) if ( nRealLen < 0 )
nRealLen = BUFFER_LEN; 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); OTools::ThrowException(m_pConnection,nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this);
if(nRealLen > BUFFER_LEN) if(nRealLen > BUFFER_LEN)
{ {
pName = new char[nRealLen+1]; pName.reset(new char[nRealLen+1]);
nRet = N3SQLColAttribute(m_aStatementHandle, nRet = N3SQLColAttribute(m_aStatementHandle,
static_cast<SQLUSMALLINT>(column), static_cast<SQLUSMALLINT>(column),
static_cast<SQLUSMALLINT>(ident), static_cast<SQLUSMALLINT>(ident),
static_cast<SQLPOINTER>(pName), static_cast<SQLPOINTER>(pName.get()),
nRealLen, nRealLen,
&nRealLen, &nRealLen,
nullptr nullptr
); );
if ( nRet == SQL_SUCCESS && nRealLen > 0) if ( nRet == SQL_SUCCESS && nRealLen > 0)
sValue = OUString(pName,nRealLen,m_pConnection->getTextEncoding()); sValue = OUString(pName.get(),nRealLen,m_pConnection->getTextEncoding());
delete [] pName;
OTools::ThrowException(m_pConnection,nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this); OTools::ThrowException(m_pConnection,nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment