Hi guys, just implemented my first kernel heap allocator and I'm kinda confused about the C++ operators...
Why does this call the delete with size_t?
I did read this page https://en.cppreference.com/w/cpp/memor ... tor_delete but it says that they're called
only if user defined implementation is provided, but if I don't provide them GCC starts complaining and it results in an undefined reference...
(I'm using C++17)
Thanks
Operators new and delete
Re: Operators new and delete
I am not a C++ expert, I mainly know C, but in the picture, it says there are 4 overloads. That tells me that is one way to define it. You could also try using a lower standard and see if that helps.
Re: Operators new and delete
It is rather trivial to implement new/delete. Here is what I use (I didn't implement all overloads as I didn't need them):
Code: Select all
inline void* operator new(size_t, void* p) { return p; }
inline void* operator new[](size_t, void* p) { return p; }
inline void* operator new(size_t size) { return ::malloc(size); }
inline void operator delete(void* p) { ::free(p); }
inline void operator delete(void* p, size_t) { ::free(p); }