I have seen this answer (Advantages of using std::make_unique over new operator) where it states:
Don't use
make_unique
if you need a custom deleter or are adopting a raw pointer from elsewhere.
This is is my code:
void CAutomaticBackupSettingsPage::GetLastBackupDate(COleDateTime& rBackupDate)
{
DATE* pDatTime = nullptr;
UINT uSize;
theApp.GetProfileBinary(_T("Options"), _T("BackupLastBackupDate"), pointer_cast<LPBYTE*>(&pDatTime), &uSize);
if (uSize == sizeof(DATE))
rBackupDate = *pDatTime;
else
rBackupDate = COleDateTime::GetCurrentTime();
delete[] pDatTime;
pDatTime = nullptr;
}
Code analysis gives me two warnings:
and
The latter warning suggests I use std::make_unique
but since my pointer data is returned from the GetProfileBinary
call, and given the statement in the related question, does that mean I should not use std::make_unique
? I admit it is something I have not done before.
The useage of GetProfileBinary
clearly states:
GetProfileBinary
allocates a buffer and returns its address in*ppData
. The caller is responsible for freeing the buffer usingdelete[]
.