replace new/delete with sp
This commit is contained in:
parent
e32731b60b
commit
ab5be0b773
71 changed files with 271 additions and 387 deletions
|
@ -31,20 +31,20 @@
|
|||
#endif
|
||||
|
||||
|
||||
static xmrig::ICpuInfo *cpuInfo = nullptr;
|
||||
static std::shared_ptr<xmrig::ICpuInfo> cpuInfo;
|
||||
|
||||
|
||||
xmrig::ICpuInfo *xmrig::Cpu::info()
|
||||
{
|
||||
if (cpuInfo == nullptr) {
|
||||
if (!cpuInfo) {
|
||||
# if defined(XMRIG_FEATURE_HWLOC)
|
||||
cpuInfo = new HwlocCpuInfo();
|
||||
cpuInfo = std::make_shared<HwlocCpuInfo>();
|
||||
# else
|
||||
cpuInfo = new BasicCpuInfo();
|
||||
cpuInfo = std::make_shared<BasicCpuInfo>();
|
||||
# endif
|
||||
}
|
||||
|
||||
return cpuInfo;
|
||||
return cpuInfo.get();
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,6 +56,5 @@ rapidjson::Value xmrig::Cpu::toJSON(rapidjson::Document &doc)
|
|||
|
||||
void xmrig::Cpu::release()
|
||||
{
|
||||
delete cpuInfo;
|
||||
cpuInfo = nullptr;
|
||||
cpuInfo.reset();
|
||||
}
|
||||
|
|
|
@ -242,7 +242,7 @@ const char *xmrig::cpu_tag()
|
|||
|
||||
|
||||
xmrig::CpuBackend::CpuBackend(Controller *controller) :
|
||||
d_ptr(new CpuBackendPrivate(controller))
|
||||
d_ptr(std::make_shared<CpuBackendPrivate>(controller))
|
||||
{
|
||||
d_ptr->workers.setBackend(this);
|
||||
}
|
||||
|
@ -250,7 +250,6 @@ xmrig::CpuBackend::CpuBackend(Controller *controller) :
|
|||
|
||||
xmrig::CpuBackend::~CpuBackend()
|
||||
{
|
||||
delete d_ptr;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ protected:
|
|||
# endif
|
||||
|
||||
private:
|
||||
CpuBackendPrivate *d_ptr;
|
||||
std::shared_ptr<CpuBackendPrivate> d_ptr;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ static constexpr uint32_t kReserveCount = 32768;
|
|||
|
||||
#ifdef XMRIG_ALGO_CN_HEAVY
|
||||
static std::mutex cn_heavyZen3MemoryMutex;
|
||||
VirtualMemory* cn_heavyZen3Memory = nullptr;
|
||||
std::shared_ptr<VirtualMemory> cn_heavyZen3Memory;
|
||||
#endif
|
||||
|
||||
} // namespace xmrig
|
||||
|
@ -87,14 +87,14 @@ xmrig::CpuWorker<N>::CpuWorker(size_t id, const CpuLaunchData &data) :
|
|||
if (!cn_heavyZen3Memory) {
|
||||
// Round up number of threads to the multiple of 8
|
||||
const size_t num_threads = ((m_threads + 7) / 8) * 8;
|
||||
cn_heavyZen3Memory = new VirtualMemory(m_algorithm.l3() * num_threads, data.hugePages, false, false, node());
|
||||
cn_heavyZen3Memory = std::make_shared<VirtualMemory>(m_algorithm.l3() * num_threads, data.hugePages, false, false, node());
|
||||
}
|
||||
m_memory = cn_heavyZen3Memory;
|
||||
}
|
||||
else
|
||||
# endif
|
||||
{
|
||||
m_memory = new VirtualMemory(m_algorithm.l3() * N, data.hugePages, false, true, node());
|
||||
m_memory = std::make_shared<VirtualMemory>(m_algorithm.l3() * N, data.hugePages, false, true, node());
|
||||
}
|
||||
|
||||
# ifdef XMRIG_ALGO_GHOSTRIDER
|
||||
|
@ -107,7 +107,7 @@ template<size_t N>
|
|||
xmrig::CpuWorker<N>::~CpuWorker()
|
||||
{
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
RxVm::destroy(m_vm);
|
||||
m_vm.reset();
|
||||
# endif
|
||||
|
||||
CnCtx::release(m_ctx, N);
|
||||
|
@ -116,7 +116,7 @@ xmrig::CpuWorker<N>::~CpuWorker()
|
|||
if (m_memory != cn_heavyZen3Memory)
|
||||
# endif
|
||||
{
|
||||
delete m_memory;
|
||||
m_memory.reset();
|
||||
}
|
||||
|
||||
# ifdef XMRIG_ALGO_GHOSTRIDER
|
||||
|
@ -148,7 +148,7 @@ void xmrig::CpuWorker<N>::allocateRandomX_VM()
|
|||
}
|
||||
else if (!dataset->get() && (m_job.currentJob().seed() != m_seed)) {
|
||||
// Update RandomX light VM with the new seed
|
||||
randomx_vm_set_cache(m_vm, dataset->cache()->get());
|
||||
randomx_vm_set_cache(m_vm.get(), dataset->cache()->get());
|
||||
}
|
||||
m_seed = m_job.currentJob().seed();
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ void xmrig::CpuWorker<N>::start()
|
|||
if (job.hasMinerSignature()) {
|
||||
job.generateMinerSignature(m_job.blob(), job.size(), miner_signature_ptr);
|
||||
}
|
||||
randomx_calculate_hash_first(m_vm, tempHash, m_job.blob(), job.size());
|
||||
randomx_calculate_hash_first(m_vm.get(), tempHash, m_job.blob(), job.size());
|
||||
}
|
||||
|
||||
if (!nextRound()) {
|
||||
|
@ -307,7 +307,7 @@ void xmrig::CpuWorker<N>::start()
|
|||
memcpy(miner_signature_saved, miner_signature_ptr, sizeof(miner_signature_saved));
|
||||
job.generateMinerSignature(m_job.blob(), job.size(), miner_signature_ptr);
|
||||
}
|
||||
randomx_calculate_hash_next(m_vm, tempHash, m_job.blob(), job.size(), m_hash);
|
||||
randomx_calculate_hash_next(m_vm.get(), tempHash, m_job.blob(), job.size(), m_hash);
|
||||
}
|
||||
else
|
||||
# endif
|
||||
|
|
|
@ -66,7 +66,7 @@ protected:
|
|||
void hashrateData(uint64_t &hashCount, uint64_t &timeStamp, uint64_t &rawHashes) const override;
|
||||
void start() override;
|
||||
|
||||
inline const VirtualMemory *memory() const override { return m_memory; }
|
||||
inline const VirtualMemory* memory() const override { return m_memory.get(); }
|
||||
inline size_t intensity() const override { return N; }
|
||||
inline void jobEarlyNotification(const Job&) override {}
|
||||
|
||||
|
@ -92,11 +92,11 @@ private:
|
|||
const Miner *m_miner;
|
||||
const size_t m_threads;
|
||||
cryptonight_ctx *m_ctx[N];
|
||||
VirtualMemory *m_memory = nullptr;
|
||||
std::shared_ptr<VirtualMemory> m_memory;
|
||||
WorkerJob<N> m_job;
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
randomx_vm *m_vm = nullptr;
|
||||
std::shared_ptr<randomx_vm> m_vm;
|
||||
Buffer m_seed;
|
||||
# endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue