On Tue, 10 Dec 2024 at 14:04, Sergei Golubchik <serg@mariadb.org> wrote:
new (thd) char[size] ();
Note the brackets before the semicolon -- they force zero initialization for scalar types, as well as for POD types:
did you test that it works?
Yes, I did. And even better news that new (thd) char[size] {}; looks much better, and also works just the same.
Apparently, one can't put a global operator new/delete definition into
a header: then a linker finds duplicates:(
even if you declare them static inline?
you can't make global operator new static :( you actually can't do it inline (without static) either, at least, formally. But I tried: inline void* operator new(size_t size){ return malloc(size); } inline void operator delete(void *ptr) noexcept { free(ptr); }; Putting this in sql_alloc.h works for gcc, but doesn't work for msvc: warning C4595: 'operator delete': non-member operator new or delete functions may not be declared inline -- Yours truly, Nikita Malyavin