diff --git a/ext/crlib/cr-alloc.h b/ext/crlib/cr-alloc.h index 09ee431..40ddf6d 100644 --- a/ext/crlib/cr-alloc.h +++ b/ext/crlib/cr-alloc.h @@ -15,12 +15,15 @@ #pragma once -#include - #include #include #include +// provide placment new to avoid stdc++ header +inline void *operator new (const size_t, void *ptr) noexcept { + return ptr; +} + CR_NAMESPACE_BEGIN // default allocator for cr-objects @@ -31,12 +34,12 @@ public: public: template T *allocate (const size_t length = 1) { - auto ptr = reinterpret_cast (malloc (length * sizeof (T))); + auto memory = reinterpret_cast (malloc (length * sizeof (T))); - if (!ptr) { + if (!memory) { plat.abort (); } - return ptr; + return memory; } template void deallocate (T *memory) { @@ -55,10 +58,10 @@ public: public: template T *create (Args &&...args) { - auto d = allocate (); - new (d) T (cr::forward (args)...); + auto memory = allocate (); + new (memory) T (cr::forward (args)...); - return d; + return memory; } template T *createArray (const size_t amount) {