Remove SmartPointer.h

This commit is contained in:
zilmar 2021-04-12 15:34:59 +09:30
parent 45f88fe58c
commit 63a5b5c431
9 changed files with 6 additions and 110 deletions

View File

@ -66,7 +66,6 @@
<ClInclude Include="path.h" />
<ClInclude Include="Platform.h" />
<ClInclude Include="Random.h" />
<ClInclude Include="SmartPointer.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="StdString.h" />
<ClInclude Include="stdtypes.h" />

View File

@ -91,9 +91,6 @@
<ClInclude Include="path.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SmartPointer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="StdString.h">
<Filter>Header Files</Filter>
</ClInclude>

View File

@ -1,94 +0,0 @@
#pragma once
// The template class definition for smart pointer
template<class _Ty>
class AUTO_PTR
{
public:
typedef _Ty element_type;
// CTOR
explicit AUTO_PTR(_Ty *pVal = 0) throw() :
m_Owns(pVal != 0),
m_AutoPtr(pVal)
{
}
// Copy CTOR
AUTO_PTR(const AUTO_PTR<_Ty>& ptrCopy) throw() :
m_Owns(ptrCopy.m_Owns),
m_AutoPtr(ptrCopy.release())
{
}
// Overloading = operator
AUTO_PTR<_Ty>& operator=(AUTO_PTR<_Ty>& ptrCopy) throw()
{
if (this != &ptrCopy)
{
if (m_AutoPtr != ptrCopy.get())
{
if (m_Owns)
{
delete m_AutoPtr;
}
m_Owns = ptrCopy.m_Owns;
}
else if (ptrCopy.m_Owns)
{
m_Owns = true;
}
m_AutoPtr = ptrCopy.release();
}
return (*this);
}
// DTOR
~AUTO_PTR()
{
if (m_Owns)
{
delete m_AutoPtr;
}
}
// Overloading * operator
_Ty& operator*() const throw()
{
return (*get());
}
// Overloading -> operator
_Ty *operator->() const throw()
{
return (get());
}
// Function to get the pointer to the class
_Ty *get() const throw()
{
return (m_AutoPtr);
}
// Function to get the pointer to the class and take ownership
_Ty *release() const throw()
{
((AUTO_PTR<_Ty> *)this)->m_Owns = false;
return (m_AutoPtr);
}
void reset(_Ty *pVal = 0) throw()
{
if (m_AutoPtr != pVal)
{
if (m_Owns)
{
delete m_AutoPtr;
}
m_AutoPtr = pVal;
m_Owns = pVal != NULL;
}
}
private:
_Ty * m_AutoPtr;
bool m_Owns;
};

View File

@ -15,5 +15,4 @@
#include "TraceModulesCommon.h"
#include "Trace.h"
#include "md5.h"
#include "SmartPointer.h"
#include "SyncEvent.h"

View File

@ -4,7 +4,6 @@
// Copyright(C) 2015 Bobby Smiles
// GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html
#include "stdafx.h"
#include <Common/SmartPointer.h>
#include "GBCart.h"
#include <time.h>
@ -683,9 +682,9 @@ static const struct parsed_cart_type* parse_cart_type(uint8_t cart_type)
bool GBCart::init_gb_cart(struct gb_cart* gb_cart, const char* gb_file)
{
const struct parsed_cart_type* type;
AUTO_PTR<uint8_t> rom;
std::unique_ptr<uint8_t> rom;
size_t rom_size = 0;
AUTO_PTR<uint8_t> ram;
std::unique_ptr<uint8_t> ram;
size_t ram_size = 0;
CFile tempFile;

View File

@ -3,7 +3,6 @@
#include "SystemGlobals.h"
#include <Common/md5.h>
#include <Common/Platform.h>
#include <Common/SmartPointer.h>
#include <Common/MemoryManagement.h>
#include <Project64-core/N64System/Mips/RegisterClass.h>
#include <memory>
@ -236,7 +235,7 @@ void CN64Disk::ClearDiskSettingID()
bool CN64Disk::AllocateDiskImage(uint32_t DiskFileSize)
{
WriteTrace(TraceN64System, TraceDebug, "Allocating memory for disk");
AUTO_PTR<uint8_t> ImageBase(new uint8_t[DiskFileSize + 0x1000]);
std::unique_ptr<uint8_t> ImageBase(new uint8_t[DiskFileSize + 0x1000]);
if (ImageBase.get() == NULL)
{
SetError(MSG_MEM_ALLOC_ERROR);
@ -256,7 +255,7 @@ bool CN64Disk::AllocateDiskImage(uint32_t DiskFileSize)
bool CN64Disk::AllocateDiskHeader()
{
WriteTrace(TraceN64System, TraceDebug, "Allocating memory for disk header forge");
AUTO_PTR<uint8_t> HeaderBase(new uint8_t[0x40 + 0x1000]);
std::unique_ptr<uint8_t> HeaderBase(new uint8_t[0x40 + 0x1000]);
if (HeaderBase.get() == NULL)
{
SetError(MSG_MEM_ALLOC_ERROR);

View File

@ -5,7 +5,6 @@
#include <Common/md5.h>
#include <Common/Platform.h>
#include <Common/MemoryManagement.h>
#include <Common/SmartPointer.h>
#include <Common/IniFileClass.h>
#include <memory>
@ -31,7 +30,7 @@ CN64Rom::~CN64Rom()
bool CN64Rom::AllocateRomImage(uint32_t RomFileSize)
{
WriteTrace(TraceN64System, TraceDebug, "Allocating memory for rom");
AUTO_PTR<uint8_t> ImageBase(new uint8_t[RomFileSize + 0x2000]);
std::unique_ptr<uint8_t> ImageBase(new uint8_t[RomFileSize + 0x2000]);
if (ImageBase.get() == NULL)
{
SetError(MSG_MEM_ALLOC_ERROR);

View File

@ -19,7 +19,6 @@
#include <Common/path.h>
#include <png/png.h>
#include <memory>
#include <Common/SmartPointer.h>
#include <Settings/Settings.h>
#include "Config.h"
@ -1167,7 +1166,7 @@ void newSwapBuffers()
info.size = sizeof(gfxLfbInfo_t);
if (gfxLfbLock(GFX_LFB_READ_ONLY, GFX_BUFFER_BACKBUFFER, GFX_LFBWRITEMODE_565, GFX_ORIGIN_UPPER_LEFT, false, &info))
{
AUTO_PTR<uint8_t> ssimg_buffer(new uint8_t[image_width * image_height * 3]);
std::unique_ptr<uint8_t> ssimg_buffer(new uint8_t[image_width * image_height * 3]);
uint8_t * ssimg = ssimg_buffer.get();
int sspos = 0;
uint32_t offset_src = info.strideInBytes * offset_y;

View File

@ -9,6 +9,5 @@
#include <Common/LogClass.h>
#include <Common/Trace.h>
#include <Common/path.h>
#include <Common/SmartPointer.h>
#include <Common/IniFileClass.h>
#include <Common/md5.h>