diff --git a/makefile b/makefile index cc9dd69..d44b5bf 100644 --- a/makefile +++ b/makefile @@ -26,7 +26,7 @@ DEPDIR::=$(OBJDIR)/dep LIBDIRS::=lib INCLUDE_DIRS::=include CFLAGS::=-std=c18 -Wall -pedantic -Wextra -CXXFLAGS::=-std=c++17 -Wall -pedantic -Wextra +CXXFLAGS::=-std=c++17 -Wall -pedantic -Wextra -fno-rtti -fno-exceptions DEBUG_CFLAGS::= DEBUG_CXXFLAGS::=-DOUR_DICK_DEBUG=2 EXT::=cpp diff --git a/src/nothrow_allocation.cpp b/src/nothrow_allocation.cpp new file mode 100644 index 0000000..c835b61 --- /dev/null +++ b/src/nothrow_allocation.cpp @@ -0,0 +1,39 @@ +/** + This file is a part of our_dick + Copyright (C) 2020 rexy712 + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +#include //size_t +#include //malloc, free +#include + +void* operator new(size_t newsize){ + return std::malloc(newsize); +} +void* operator new(size_t newsize, std::align_val_t al){ + return ::operator new(newsize, al, std::nothrow); +} +void operator delete(void* ptr)noexcept{ + std::free(ptr); +} +void operator delete(void* ptr, std::align_val_t al)noexcept{ + ::operator delete(ptr, al, std::nothrow); +} + +//GCC warns without this one for some reason +void operator delete(void* ptr, size_t)noexcept{ + ::operator delete(ptr); +}