Small fixes

This commit is contained in:
SChernykh 2021-08-29 00:13:53 +02:00
parent 8a26498b66
commit 8e29abd906
3 changed files with 16 additions and 9 deletions

View file

@ -117,19 +117,26 @@ FORCEINLINE static void remove_allocation(void* p)
return;
}
}
if (!found) {
// Someone tried to deallocate a pointer that wasn't allocated before
__debugbreak();
// Someone tried to deallocate a pointer that wasn't allocated before
__debugbreak();
}
FORCEINLINE static void* allocate_noexcept(size_t n) noexcept
{
void* p = malloc(n + sizeof(TrackedAllocation));
if (p) {
add_alocation(p, n);
}
return p;
}
FORCEINLINE static void* allocate(size_t n)
{
void* p = malloc(n + sizeof(TrackedAllocation));
void* p = allocate_noexcept(n);
if (!p) {
throw std::bad_alloc();
}
add_alocation(p, n);
return p;
}
@ -202,8 +209,8 @@ void memory_tracking_stop()
NOINLINE void* operator new(size_t n) { return p2pool::allocate(n); }
NOINLINE void* operator new[](size_t n) { return p2pool::allocate(n); }
NOINLINE void* operator new(size_t n, const std::nothrow_t&) noexcept { return p2pool::allocate(n); }
NOINLINE void* operator new[](size_t n, const std::nothrow_t&) noexcept { return p2pool::allocate(n); }
NOINLINE void* operator new(size_t n, const std::nothrow_t&) noexcept { return p2pool::allocate_noexcept(n); }
NOINLINE void* operator new[](size_t n, const std::nothrow_t&) noexcept { return p2pool::allocate_noexcept(n); }
NOINLINE void operator delete(void* p) noexcept { p2pool::deallocate(p); }
NOINLINE void operator delete[](void* p) noexcept { p2pool::deallocate(p); }
NOINLINE void operator delete(void* p, size_t) noexcept { p2pool::deallocate(p); }

View file

@ -657,7 +657,7 @@ void SideChain::print_status()
"\nYour hashrate (est) = " << log::Hashrate(hashrate_est) <<
"\nPPLNS window = " << total_blocks_in_window << " blocks (+" << total_uncles_in_window << " uncles, " << total_orphans << " orphans)"
"\nYour shares = " << our_blocks_in_window << " blocks (+" << our_uncles_in_window << " uncles, " << our_orphans << " orphans)"
"\nNext payout = " << log::XMRAmount(next_payout)
"\nNext payout (est) = " << log::XMRAmount(next_payout)
);
}

View file

@ -30,7 +30,7 @@ public:
struct Client;
typedef Client* (*allocate_client_callback)();
TCPServer(allocate_client_callback allocate_new_client);
explicit TCPServer(allocate_client_callback allocate_new_client);
virtual ~TCPServer();
template<typename T>