Use unique_ptr instead of auto_ptr where available (and define a macro to pick which one to use); fix a few other remaining warnings.
This commit is contained in:
parent
4cb15a741a
commit
5c1cfe4702
|
@ -1016,7 +1016,7 @@ cDoubleIconvConverter::Convert(
|
|||
//
|
||||
size_t nBufBytes = nChars * MB_LEN_MAX;
|
||||
ntmbs_t pszBuffer = (ntmbs_t)::operator new( nBufBytes + 1 );
|
||||
std::auto_ptr<mbchar_t> pBuf( pszBuffer );
|
||||
TW_UNIQUE_PTR<mbchar_t> pBuf( pszBuffer );
|
||||
|
||||
//
|
||||
// do first conversion
|
||||
|
@ -1074,7 +1074,7 @@ cDoubleIconvConverter::Convert(
|
|||
//
|
||||
size_t nBufBytes = nBytes * MB_LEN_MAX;
|
||||
ntmbs_t pszBuffer = (ntmbs_t)::operator new( nBufBytes + 1 );
|
||||
std::auto_ptr<mbchar_t> pBuf( pszBuffer );
|
||||
TW_UNIQUE_PTR<mbchar_t> pBuf( pszBuffer );
|
||||
|
||||
//
|
||||
// do first conversion
|
||||
|
|
|
@ -207,6 +207,7 @@ char *getenv(); /* get variable from environment */
|
|||
* on some systems, this is a library function, so define STRDUP
|
||||
* if it is on yours
|
||||
*/
|
||||
#if 0
|
||||
#ifdef STRDUP
|
||||
# ifndef __STDC__
|
||||
char *strdup();
|
||||
|
@ -230,7 +231,7 @@ char *getenv(); /* get variable from environment */
|
|||
return(p);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //0
|
||||
|
||||
/*
|
||||
* allocate space for an array of pointers, OR
|
||||
|
|
|
@ -135,9 +135,6 @@ void cRefCountObj::AddRef() const
|
|||
|
||||
void cRefCountObj::Release() const
|
||||
{
|
||||
if (this == 0)
|
||||
return;
|
||||
|
||||
if (--mRefCount == 0)
|
||||
{
|
||||
Delete();
|
||||
|
|
|
@ -187,5 +187,16 @@ inline int64 SWAPBYTES64(int64 i)
|
|||
|
||||
#endif //WORDS_BIGENDIAN
|
||||
|
||||
////////////////////////////////////////////
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
# define TW_UNIQUE_PTR std::unique_ptr
|
||||
#else
|
||||
# define TW_UNIQUE_PTR std::auto_ptr
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // __TYPES_H
|
||||
|
||||
|
|
|
@ -5,6 +5,12 @@
|
|||
#include "queue.h"
|
||||
#include <memory>
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
# define TW_UNIQUE_PTR std::unique_ptr
|
||||
#else
|
||||
# define TW_UNIQUE_PTR std::auto_ptr
|
||||
#endif
|
||||
|
||||
Filter::Filter(BufferedTransformation *outQ)
|
||||
: outQueue(outQ ? outQ : new ByteQueue)
|
||||
{
|
||||
|
@ -17,7 +23,7 @@ Filter::Filter(const Filter &source)
|
|||
|
||||
void Filter::Detach(BufferedTransformation *newOut)
|
||||
{
|
||||
std::auto_ptr<BufferedTransformation> out(newOut ? newOut : new ByteQueue);
|
||||
TW_UNIQUE_PTR<BufferedTransformation> out(newOut ? newOut : new ByteQueue);
|
||||
outQueue->Close();
|
||||
outQueue->TransferTo(*out);
|
||||
outQueue.reset(out.release());
|
||||
|
|
|
@ -5,6 +5,12 @@
|
|||
#include "queue.h"
|
||||
#include <memory>
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
# define TW_UNIQUE_PTR std::unique_ptr
|
||||
#else
|
||||
# define TW_UNIQUE_PTR std::auto_ptr
|
||||
#endif
|
||||
|
||||
Fork::Fork(int n, BufferedTransformation *const *givenOutPorts)
|
||||
: numberOfPorts(n), outPorts(n)
|
||||
{
|
||||
|
@ -21,7 +27,7 @@ void Fork::SelectOutPort(int portNumber)
|
|||
|
||||
void Fork::Detach(BufferedTransformation *newOut)
|
||||
{
|
||||
std::auto_ptr<BufferedTransformation> out(newOut ? newOut : new ByteQueue);
|
||||
TW_UNIQUE_PTR<BufferedTransformation> out(newOut ? newOut : new ByteQueue);
|
||||
outPorts[currentPort]->Close();
|
||||
outPorts[currentPort]->TransferTo(*out);
|
||||
outPorts[currentPort].reset(out.release());
|
||||
|
|
|
@ -100,7 +100,7 @@ static void util_ProcessDir( cDbDataSourceIter dbIter, iFCODataSourceIter* pIter
|
|||
{
|
||||
dbIter.AddChildArray();
|
||||
}
|
||||
std::auto_ptr<iFCODataSourceIter> pCopy( pIter->CreateCopy() );
|
||||
TW_UNIQUE_PTR<iFCODataSourceIter> pCopy( pIter->CreateCopy() );
|
||||
util_ProcessDir( dbIter, pCopy.get(), pSpec, pPC, pPD );
|
||||
//
|
||||
// if no files were added, remove the child array...
|
||||
|
@ -122,7 +122,7 @@ void cGenerateDb::Execute( const cFCOSpecList& specList, cHierDatabase& db, iFCO
|
|||
{
|
||||
// TODO -- assert the db is empty or clear it out myself!
|
||||
|
||||
std::auto_ptr<iFCODataSourceIter> pDSIter(iTWFactory::GetInstance()->CreateDataSourceIter());
|
||||
TW_UNIQUE_PTR<iFCODataSourceIter> pDSIter(iTWFactory::GetInstance()->CreateDataSourceIter());
|
||||
|
||||
//
|
||||
// set up the database's iterator...
|
||||
|
@ -139,7 +139,7 @@ void cGenerateDb::Execute( const cFCOSpecList& specList, cHierDatabase& db, iFCO
|
|||
//
|
||||
// this is the object that will calculate all of the properties of the fcos.
|
||||
//
|
||||
std::auto_ptr<iFCOPropCalc> pPC(iTWFactory::GetInstance()->CreatePropCalc());
|
||||
TW_UNIQUE_PTR<iFCOPropCalc> pPC(iTWFactory::GetInstance()->CreatePropCalc());
|
||||
pPC->SetErrorBucket( pBucket );
|
||||
if( flags & FLAG_ERASE_FOOTPRINTS_GD )
|
||||
{
|
||||
|
@ -193,7 +193,7 @@ void cGenerateDb::Execute( const cFCOSpecList& specList, cHierDatabase& db, iFCO
|
|||
{
|
||||
dbIter.AddChildArray();
|
||||
}
|
||||
std::auto_ptr<iFCODataSourceIter> pCopy( pDSIter->CreateCopy() );
|
||||
TW_UNIQUE_PTR<iFCODataSourceIter> pCopy( pDSIter->CreateCopy() );
|
||||
util_ProcessDir( dbIter, pCopy.get(), specIter.Spec(), pPC.get(), pPD );
|
||||
//
|
||||
// if no files were added, remove the child array...
|
||||
|
|
|
@ -90,7 +90,7 @@ void cIntegrityCheck::ProcessAddedFCO( cDbDataSourceIter dbIter, iFCODataSourceI
|
|||
// to done...
|
||||
//
|
||||
while( ! dbIter.Done() ) dbIter.Next();
|
||||
std::auto_ptr<iFCODataSourceIter> pCopy( pIter->CreateCopy() );
|
||||
TW_UNIQUE_PTR<iFCODataSourceIter> pCopy( pIter->CreateCopy() );
|
||||
ProcessDir( dbIter, pCopy.get() );
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ void cIntegrityCheck::ProcessChangedFCO( cDbDataSourceIter dbIter, iFCODataSourc
|
|||
{
|
||||
if( pIter->CanDescend() || dbIter.CanDescend() )
|
||||
{
|
||||
std::auto_ptr<iFCODataSourceIter> pCopy( pIter->CreateCopy() );
|
||||
TW_UNIQUE_PTR<iFCODataSourceIter> pCopy( pIter->CreateCopy() );
|
||||
ProcessDir( dbIter, pCopy.get() );
|
||||
}
|
||||
}
|
||||
|
@ -453,7 +453,7 @@ void cIntegrityCheck::Execute( uint32 flags )
|
|||
mFlags = flags;
|
||||
// create the data source iterator
|
||||
//
|
||||
std::auto_ptr<iFCODataSourceIter> pDSIter(iTWFactory::GetInstance()->CreateDataSourceIter());
|
||||
TW_UNIQUE_PTR<iFCODataSourceIter> pDSIter(iTWFactory::GetInstance()->CreateDataSourceIter());
|
||||
//
|
||||
// set up the database's iterator...
|
||||
// I assume the current genre is correct...
|
||||
|
@ -560,7 +560,7 @@ void cIntegrityCheck::ExecuteOnObjectList( const std::list<cFCOName>& fcoNames,
|
|||
//
|
||||
// create the data source iterator
|
||||
//
|
||||
std::auto_ptr<iFCODataSourceIter> pDSIter(iTWFactory::GetInstance()->CreateDataSourceIter());
|
||||
TW_UNIQUE_PTR<iFCODataSourceIter> pDSIter(iTWFactory::GetInstance()->CreateDataSourceIter());
|
||||
//
|
||||
// set up the database's iterator...
|
||||
// I assume the current genre is correct...
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "core/errorbucketimpl.h"
|
||||
#include "core/usernotifystdout.h"
|
||||
#include "core/timebomb.h"
|
||||
#include <memory> // for auto_ptr
|
||||
#include <memory> // for auto_ptr / unique_ptr
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
|
||||
|
@ -133,7 +133,7 @@ int __cdecl _tmain( int argc, const TCHAR* argv[ ], const TCHAR* envp[ ] )
|
|||
|
||||
|
||||
// first, get the right mode...
|
||||
std::auto_ptr<iTWMode> pMode(cTWCmdLine::GetMode(argc, argv));
|
||||
TW_UNIQUE_PTR<iTWMode> pMode(cTWCmdLine::GetMode(argc, argv));
|
||||
if(! pMode.get())
|
||||
{
|
||||
// no valid mode passed; GetMode will display an appropriate string (include usage statement)
|
||||
|
|
|
@ -1129,7 +1129,7 @@ int cTWModeIC::Execute(cErrorQueue* pQueue)
|
|||
if( ! dbIter.Done() )
|
||||
{
|
||||
cGenreSwitcher::GetInstance()->SelectGenre( (cGenre::Genre)dbIter.GetGenre() );
|
||||
std::auto_ptr<iParserGenreUtil> pParseUtil (iTWFactory::GetInstance()->CreateParserGenreUtil());
|
||||
TW_UNIQUE_PTR<iParserGenreUtil> pParseUtil (iTWFactory::GetInstance()->CreateParserGenreUtil());
|
||||
//
|
||||
// I have to turn this into a list of cFCONames
|
||||
//
|
||||
|
|
|
@ -531,7 +531,7 @@ static bool EmailReportTo(const TSTRING &toAddress, const cFCOReportHeader& head
|
|||
const cTWModeCommon *modeCommon,
|
||||
const bool bForceFullReport)
|
||||
{
|
||||
std::auto_ptr<cMailMessage> reportMail;
|
||||
TW_UNIQUE_PTR<cMailMessage> reportMail;
|
||||
|
||||
// allocate the right kind of emailer object based on what came out of the config file.
|
||||
switch (modeCommon->mMailMethod)
|
||||
|
@ -540,10 +540,10 @@ static bool EmailReportTo(const TSTRING &toAddress, const cFCOReportHeader& head
|
|||
ASSERT(false);
|
||||
return false;
|
||||
case cMailMessage::MAIL_BY_SMTP:
|
||||
reportMail = std::auto_ptr<cMailMessage>(new cSMTPMailMessage(modeCommon->mSmtpHost, modeCommon->mSmtpPort));
|
||||
reportMail = TW_UNIQUE_PTR<cMailMessage>(new cSMTPMailMessage(modeCommon->mSmtpHost, modeCommon->mSmtpPort));
|
||||
break;
|
||||
case cMailMessage::MAIL_BY_PIPE:
|
||||
reportMail = std::auto_ptr<cMailMessage>(new cPipedMailMessage(modeCommon->mMailProgram));
|
||||
reportMail = TW_UNIQUE_PTR<cMailMessage>(new cPipedMailMessage(modeCommon->mMailProgram));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -685,7 +685,7 @@ bool cTWCmdLineUtil::EmailReport(const cFCOReportHeader& header, const cFCORepor
|
|||
|
||||
bool cTWCmdLineUtil::SendEmailTestMessage(const TSTRING &mAddress, const cTWModeCommon *modeCommon)
|
||||
{
|
||||
std::auto_ptr<cMailMessage> reportMail;
|
||||
TW_UNIQUE_PTR<cMailMessage> reportMail;
|
||||
|
||||
// allocate the right kind of emailer object based on what came out of the config file.
|
||||
switch (modeCommon->mMailMethod)
|
||||
|
@ -694,10 +694,10 @@ bool cTWCmdLineUtil::SendEmailTestMessage(const TSTRING &mAddress, const cTWMode
|
|||
ASSERT(false);
|
||||
return false;
|
||||
case cMailMessage::MAIL_BY_SMTP:
|
||||
reportMail = std::auto_ptr<cMailMessage>(new cSMTPMailMessage(modeCommon->mSmtpHost, modeCommon->mSmtpPort));
|
||||
reportMail = TW_UNIQUE_PTR<cMailMessage>(new cSMTPMailMessage(modeCommon->mSmtpHost, modeCommon->mSmtpPort));
|
||||
break;
|
||||
case cMailMessage::MAIL_BY_PIPE:
|
||||
reportMail = std::auto_ptr<cMailMessage>(new cPipedMailMessage(modeCommon->mMailProgram));
|
||||
reportMail = TW_UNIQUE_PTR<cMailMessage>(new cPipedMailMessage(modeCommon->mMailProgram));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1247,7 +1247,7 @@ void cTWUtil::ParseObjectList( cTWUtil::GenreObjList& listOut, const cTWUtil::Ob
|
|||
//
|
||||
if( g == cGenre::GENRE_INVALID )
|
||||
{
|
||||
std::auto_ptr<iParserGenreUtil> pParseUtil (iTWFactory::GetInstance()->CreateParserGenreUtil());
|
||||
TW_UNIQUE_PTR<iParserGenreUtil> pParseUtil (iTWFactory::GetInstance()->CreateParserGenreUtil());
|
||||
if( ! pParseUtil->IsAbsolutePath( *i ) )
|
||||
throw eTWUnknownSectionName( *i );
|
||||
}
|
||||
|
@ -1310,7 +1310,7 @@ void cTWUtil::ParseObjectList( cTWUtil::GenreObjList& listOut, const cTWUtil::Ob
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
cFCOName cTWUtil::ParseObjectName( const TSTRING& fcoName )
|
||||
{
|
||||
std::auto_ptr<iParserGenreUtil> pParseUtil (iTWFactory::GetInstance()->CreateParserGenreUtil());
|
||||
TW_UNIQUE_PTR<iParserGenreUtil> pParseUtil (iTWFactory::GetInstance()->CreateParserGenreUtil());
|
||||
cFCOName name( iTWFactory::GetInstance()->GetNameInfo() );
|
||||
//
|
||||
// make sure the fco name is a full path...
|
||||
|
|
|
@ -94,7 +94,7 @@ int __cdecl _tmain( int argc, const TCHAR* argv[ ], const TCHAR* envp[ ] )
|
|||
|
||||
|
||||
// first, get the right mode...
|
||||
std::auto_ptr<iTWAMode> pMode(cTWAdminCmdLine::GetMode(argc, argv));
|
||||
TW_UNIQUE_PTR<iTWAMode> pMode(cTWAdminCmdLine::GetMode(argc, argv));
|
||||
if(! pMode.get())
|
||||
{
|
||||
// no valid mode passed; GetMode will display an appropriate string (include usage statement)
|
||||
|
|
|
@ -128,7 +128,7 @@ int __cdecl _tmain( int argc, const TCHAR* argv[ ] )
|
|||
}
|
||||
|
||||
// Next, set the mode... exit with error if now valid mode specified.
|
||||
std::auto_ptr<iTWMode> pMode(cTWPrintCmdLine::GetMode(argc, argv));
|
||||
TW_UNIQUE_PTR<iTWMode> pMode(cTWPrintCmdLine::GetMode(argc, argv));
|
||||
if(! pMode.get())
|
||||
{
|
||||
// no valid mode passed; GetMode will display an appropriate string (include usage statement)
|
||||
|
|
|
@ -182,9 +182,10 @@ char NonZeroChar( char ch )
|
|||
}
|
||||
|
||||
// mbchar_t to dbchar_t
|
||||
//TestMbToDb in codeconvert_t.cpp seems to hit an infinite loop or runs verrrry long; ifdef'd"
|
||||
void TestMbToDb()
|
||||
{
|
||||
TCERR << "TODO: TestMbToDb in codeconvert_t.cpp seems to hit an infinite loop or runs verrrry long; ifdef'd" << std::endl;
|
||||
TCERR << "\nTODO: TestMbToDb in codeconvert_t.cpp is flaky & needs to be fixed/replaced; currently disabled." << std::endl;
|
||||
#if 0
|
||||
std::string s;
|
||||
s.resize( 0x10000 * 2 ); // two bytes for each combination
|
||||
|
|
|
@ -39,7 +39,7 @@ class cRefCountTestObj : public cRefCountObj
|
|||
public:
|
||||
cRefCountTestObj();
|
||||
|
||||
virtual void Release();
|
||||
virtual void Release() const;
|
||||
|
||||
void AddChild(cRefCountTestObj* pChild);
|
||||
|
||||
|
@ -74,7 +74,7 @@ void cRefCountTestObj::AddChild(cRefCountTestObj* pChild)
|
|||
mChildren.push_back(pChild);
|
||||
}
|
||||
|
||||
void cRefCountTestObj::Release()
|
||||
void cRefCountTestObj::Release() const
|
||||
{
|
||||
cRefCountObj::Release();
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ void TestUnixFSServices()
|
|||
d.TraceDebug("name: %d entries\n", v.size());
|
||||
|
||||
std::vector <TSTRING>::iterator p;
|
||||
int n = 0;
|
||||
size_t n = 0;
|
||||
for (p = v.begin(); p != v.end(); p++) {
|
||||
d.TraceDetail(" %s\n", p->c_str());
|
||||
n++;
|
||||
|
|
Loading…
Reference in New Issue