Skip to content

Commit

Permalink
Remove unused methods and code.
Browse files Browse the repository at this point in the history
Change-Id: Ie6d15e6f56383e491240b4868f4746aee5fa8ddc
  • Loading branch information
MichalMrozek authored and Compute-Runtime-Automation committed Aug 16, 2018
1 parent 524737a commit 55901f3
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions unit_tests/helpers/memory_management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ std::atomic<size_t> indexAllocation(0);
std::atomic<size_t> indexDeallocation(0);
bool logTraces = false;
int fastLeakDetectionMode = 0;
bool memsetNewAllocations = false;

AllocationEvent eventsAllocated[maxEvents];
AllocationEvent eventsDeallocated[maxEvents];
Expand Down Expand Up @@ -246,40 +245,23 @@ using MemoryManagement::allocate;
using MemoryManagement::AllocationEvent;
using MemoryManagement::deallocate;

NO_SANITIZE
inline void initMemory(void *p, size_t size) {
if ((p == nullptr) || (false == MemoryManagement::memsetNewAllocations)) {
return;
}

memset(p, 0, size);
}

#if defined(_WIN32)
#pragma warning(disable : 4290)
#endif
void *operator new(size_t size) {
void *p = allocate<AllocationEvent::EVENT_NEW, AllocationEvent::EVENT_NEW_FAIL>(size);
initMemory(p, size);
return p;
return allocate<AllocationEvent::EVENT_NEW, AllocationEvent::EVENT_NEW_FAIL>(size);
}

void *operator new(size_t size, const std::nothrow_t &) noexcept {
void *p = allocate<AllocationEvent::EVENT_NEW_NOTHROW, AllocationEvent::EVENT_NEW_NOTHROW_FAIL>(size, std::nothrow);
initMemory(p, size);
return p;
return allocate<AllocationEvent::EVENT_NEW_NOTHROW, AllocationEvent::EVENT_NEW_NOTHROW_FAIL>(size, std::nothrow);
}

void *operator new[](size_t size) {
void *p = allocate<AllocationEvent::EVENT_NEW_ARRAY, AllocationEvent::EVENT_NEW_ARRAY_FAIL>(size);
initMemory(p, size);
return p;
return allocate<AllocationEvent::EVENT_NEW_ARRAY, AllocationEvent::EVENT_NEW_ARRAY_FAIL>(size);
}

void *operator new[](size_t size, const std::nothrow_t &t) noexcept {
void *p = allocate<AllocationEvent::EVENT_NEW_ARRAY_NOTHROW, AllocationEvent::EVENT_NEW_ARRAY_NOTHROW_FAIL>(size, std::nothrow);
initMemory(p, size);
return p;
return allocate<AllocationEvent::EVENT_NEW_ARRAY_NOTHROW, AllocationEvent::EVENT_NEW_ARRAY_NOTHROW_FAIL>(size, std::nothrow);
}

void operator delete(void *p) noexcept {
Expand Down

0 comments on commit 55901f3

Please sign in to comment.