mirror of
https://github.com/xmrig/xmrig.git
synced 2025-12-24 21:32:47 -05:00
Merge branch 'master' into mo
This commit is contained in:
@@ -42,7 +42,7 @@ static inline char *createUserAgent()
|
||||
{
|
||||
const size_t max = 160;
|
||||
|
||||
char *buf = new char[max];
|
||||
char *buf = static_cast<char *>(malloc(max));
|
||||
|
||||
# ifdef XMRIG_NVIDIA_PROJECT
|
||||
const int cudaVersion = cuda_get_runtime_version();
|
||||
|
||||
@@ -56,7 +56,7 @@ static inline char *createUserAgent()
|
||||
{
|
||||
const size_t max = 160;
|
||||
|
||||
char *buf = new char[max];
|
||||
char *buf = static_cast<char *>(malloc(max));
|
||||
int length = snprintf(buf, max, "%s/%s (Linux ", APP_NAME, APP_VERSION);
|
||||
|
||||
# if defined(__x86_64__)
|
||||
|
||||
@@ -60,7 +60,7 @@ static inline char *createUserAgent()
|
||||
const auto osver = winOsVersion();
|
||||
const size_t max = 160;
|
||||
|
||||
char *buf = new char[max];
|
||||
char *buf = static_cast<char *>(malloc(max));
|
||||
int length = snprintf(buf, max, "%s/%s (Windows NT %lu.%lu", APP_NAME, APP_VERSION, osver.dwMajorVersion, osver.dwMinorVersion);
|
||||
|
||||
# if defined(__x86_64__) || defined(_M_AMD64)
|
||||
|
||||
@@ -97,7 +97,7 @@ Pool::Pool(const char *host, uint16_t port, const char *user, const char *passwo
|
||||
const size_t size = m_host.size() + 8;
|
||||
assert(size > 8);
|
||||
|
||||
char *url = new char[size]();
|
||||
char *url = static_cast<char *>(malloc(size));
|
||||
snprintf(url, size - 1, "%s:%d", m_host.data(), m_port);
|
||||
|
||||
m_url = url;
|
||||
@@ -171,8 +171,9 @@ bool Pool::parse(const char *url)
|
||||
}
|
||||
|
||||
const size_t size = port++ - base + 1;
|
||||
char *host = new char[size]();
|
||||
char *host = static_cast<char *>(malloc(size));
|
||||
memcpy(host, base, size - 1);
|
||||
host[size - 1] = 0;
|
||||
|
||||
m_host = host;
|
||||
m_port = static_cast<uint16_t>(strtol(port, nullptr, 10));
|
||||
@@ -188,7 +189,7 @@ bool Pool::setUserpass(const char *userpass)
|
||||
return false;
|
||||
}
|
||||
|
||||
char *user = new char[p - userpass + 1]();
|
||||
char *user = static_cast<char *>(malloc(p - userpass + 1));
|
||||
strncpy(user, userpass, p - userpass);
|
||||
|
||||
m_user = user;
|
||||
@@ -279,7 +280,7 @@ bool Pool::parseIPv6(const char *addr)
|
||||
}
|
||||
|
||||
const size_t size = end - addr;
|
||||
char *host = new char[size]();
|
||||
char *host = static_cast<char *>(malloc(size));
|
||||
memcpy(host, addr + 1, size - 1);
|
||||
|
||||
m_host = host;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
|
||||
#include "workers/Handle.h"
|
||||
#include "interfaces/IWorker.h"
|
||||
|
||||
|
||||
Handle::Handle(xmrig::IThread *config, uint32_t offset, size_t totalWays) :
|
||||
@@ -33,6 +34,7 @@ Handle::Handle(xmrig::IThread *config, uint32_t offset, size_t totalWays) :
|
||||
{
|
||||
}
|
||||
|
||||
Handle::~Handle() { if (m_worker) delete m_worker; }
|
||||
|
||||
void Handle::join()
|
||||
{
|
||||
|
||||
@@ -40,6 +40,7 @@ class Handle
|
||||
{
|
||||
public:
|
||||
Handle(xmrig::IThread *config, uint32_t offset, size_t totalWays);
|
||||
~Handle();
|
||||
void join();
|
||||
void start(void (*callback) (void *));
|
||||
|
||||
|
||||
@@ -71,6 +71,17 @@ Hashrate::Hashrate(size_t threads, xmrig::Controller *controller) :
|
||||
}
|
||||
}
|
||||
|
||||
Hashrate::~Hashrate()
|
||||
{
|
||||
for (size_t i = 0; i < m_threads; i++) {
|
||||
delete [] m_counts[i];
|
||||
delete [] m_timestamps[i];
|
||||
}
|
||||
delete [] m_counts;
|
||||
delete [] m_timestamps;
|
||||
delete [] m_top;
|
||||
}
|
||||
|
||||
|
||||
double Hashrate::calc(size_t ms) const
|
||||
{
|
||||
|
||||
@@ -44,6 +44,7 @@ public:
|
||||
};
|
||||
|
||||
Hashrate(size_t threads, xmrig::Controller *controller);
|
||||
~Hashrate();
|
||||
double calc(size_t ms) const;
|
||||
double calc(size_t threadId, size_t ms) const;
|
||||
void add(size_t threadId, uint64_t count, uint64_t timestamp);
|
||||
|
||||
Reference in New Issue
Block a user