1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- #include "core/utils/New.hpp"
- #include <stdlib.h>
- #include "ErrorSimulator.hpp"
- void* operator new(size_t bytes, const NoThrow&) noexcept {
- #ifdef ERROR_SIMULATOR
- if(Core::Fail::leftAllocations > 0) {
- Core::Fail::leftAllocations--;
- } else if(Core::Fail::leftAllocations == 0) {
- return nullptr;
- }
- #endif
- return malloc(bytes);
- }
- void* operator new[](size_t bytes, const NoThrow&) noexcept {
- #ifdef ERROR_SIMULATOR
- if(Core::Fail::leftAllocations > 0) {
- Core::Fail::leftAllocations--;
- } else if(Core::Fail::leftAllocations == 0) {
- return nullptr;
- }
- #endif
- return malloc(bytes);
- }
- void operator delete(void* p) noexcept {
- free(p);
- }
- void operator delete[](void* p) noexcept {
- free(p);
- }
- void operator delete(void* p, size_t bytes) noexcept {
- (void)bytes;
- operator delete(p);
- }
- void operator delete[](void* p, size_t bytes) noexcept {
- (void)bytes;
- free(p);
- }
- void* operator new(size_t bytes, void* p) noexcept {
- (void)bytes;
- return p;
- }
|