Created
October 29, 2014 22:54
-
-
Save chadaustin/e544be3849bc47f2c0a4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <new> | |
#include <cstdlib> | |
// malloc cannot fail on Emscripten, so don't even bother checking. | |
// We also know that `malloc(0)` will return a non-null pointer, so | |
// don't check that `count` is positive.. | |
__attribute__((__always_inline__)) void* operator new(std::size_t count) { | |
return std::malloc(count); | |
} | |
__attribute__((__always_inline__)) void* operator new[](std::size_t count) { | |
return std::malloc(count); | |
} | |
__attribute__((__always_inline__)) void* operator new(std::size_t count, const std::nothrow_t&) { | |
return std::malloc(count); | |
} | |
__attribute__((__always_inline__)) void* operator new[](std::size_t count, const std::nothrow_t&) { | |
return std::malloc(count); | |
} | |
__attribute__((__always_inline__)) void operator delete(void* ptr) noexcept { | |
std::free(ptr); | |
} | |
__attribute__((__always_inline__)) void operator delete[](void* ptr) noexcept { | |
std::free(ptr); | |
} | |
__attribute__((__always_inline__)) void operator delete(void* ptr, const std::nothrow_t&) noexcept { | |
std::free(ptr); | |
} | |
__attribute__((__always_inline__)) void operator delete[](void* ptr, const std::nothrow_t&) noexcept { | |
std::free(ptr); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment