new cannot return nullptr

unless we are using std::nothrow

Change-Id: I3bdd13c8ce18f4e977f18ee5196311bf4fc62de0
Reviewed-on: https://gerrit.libreoffice.org/38998
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2017-06-20 08:52:10 +02:00
parent 67a0889450
commit 05f67637fc
6 changed files with 6 additions and 37 deletions

View File

@@ -315,10 +315,6 @@ get_full_path(const NS_tchar *relpath)
size_t lendestpath = NS_tstrlen(destpath);
size_t lenrelpath = NS_tstrlen(relpath);
NS_tchar *s = new NS_tchar[lendestpath + lenrelpath + 2];
if (!s)
{
return nullptr;
}
NS_tchar *c = s;

View File

@@ -734,8 +734,6 @@ oslFileHandle osl::detail::createFileHandleFromFD( int fd )
return nullptr; // EBADF
FileHandle_Impl * pImpl = new FileHandle_Impl (fd);
if (pImpl == nullptr)
return nullptr; // ENOMEM
// assume writeable
pImpl->m_state |= FileHandle_Impl::STATE_WRITEABLE;
@@ -809,11 +807,6 @@ openMemoryAsFile( void *address, size_t size, oslFileHandle *pHandle, const char
{
oslFileError eRet;
FileHandle_Impl * pImpl = new FileHandle_Impl (-1, FileHandle_Impl::KIND_MEM, path);
if (!pImpl)
{
eRet = oslTranslateFileError (OSL_FET_ERROR, ENOMEM);
return eRet;
}
pImpl->m_size = sal::static_int_cast< sal_uInt64 >(size);
*pHandle = (oslFileHandle)(pImpl);
@@ -1015,12 +1008,6 @@ openFilePath( const char *cpFilePath, oslFileHandle* pHandle, sal_uInt32 uFlags,
/* allocate memory for impl structure */
FileHandle_Impl * pImpl = new FileHandle_Impl (fd, FileHandle_Impl::KIND_FD, cpFilePath);
if (!pImpl)
{
eRet = oslTranslateFileError (OSL_FET_ERROR, ENOMEM);
(void) close(fd);
return eRet;
}
if (flags & O_RDWR)
pImpl->m_state |= FileHandle_Impl::STATE_WRITEABLE;
pImpl->m_size = sal::static_int_cast< sal_uInt64 >(aFileStat.st_size);

View File

@@ -148,13 +148,10 @@ static void osl_thread_init_Impl()
Thread_Impl* osl_thread_construct_Impl()
{
Thread_Impl* pImpl = new Thread_Impl;
if (pImpl)
{
memset (pImpl, 0, sizeof(Thread_Impl));
memset (pImpl, 0, sizeof(Thread_Impl));
pthread_mutex_init (&(pImpl->m_Lock), PTHREAD_MUTEXATTR_DEFAULT);
pthread_cond_init (&(pImpl->m_Cond), PTHREAD_CONDATTR_DEFAULT);
}
pthread_mutex_init (&(pImpl->m_Lock), PTHREAD_MUTEXATTR_DEFAULT);
pthread_cond_init (&(pImpl->m_Cond), PTHREAD_CONDATTR_DEFAULT);
return pImpl;
}

View File

@@ -677,12 +677,6 @@ SAL_CALL osl_createFileHandleFromOSHandle (
return nullptr; // EINVAL
FileHandle_Impl * pImpl = new FileHandle_Impl(hFile);
if (pImpl == nullptr)
{
// cleanup and fail
(void) ::CloseHandle(hFile);
return nullptr; // ENOMEM
}
/* check for regular file */
if (FILE_TYPE_DISK == GetFileType(hFile))

View File

@@ -78,8 +78,6 @@ bool ScCollection::AtInsert(sal_uInt16 nIndex, ScDataObject* pScDataObject)
if (nCount == nLimit)
{
ScDataObject** pNewItems = new ScDataObject*[nLimit + nDelta];
if (!pNewItems)
return false;
nLimit = sal::static_int_cast<sal_uInt16>( nLimit + nDelta );
memcpy(pNewItems, pItems, nCount * sizeof(ScDataObject*));
delete[] pItems;

View File

@@ -1714,13 +1714,10 @@ namespace {
CGPoint* makeCGptArray(sal_uInt32 nPoints, const SalPoint* pPtAry)
{
CGPoint *CGpoints = new CGPoint[nPoints];
if ( CGpoints )
for(sal_uLong i=0;i<nPoints;i++)
{
for(sal_uLong i=0;i<nPoints;i++)
{
CGpoints[i].x = pPtAry[i].mnX;
CGpoints[i].y = pPtAry[i].mnY;
}
CGpoints[i].x = pPtAry[i].mnX;
CGpoints[i].y = pPtAry[i].mnY;
}
return CGpoints;
}