sI'm on Windows, and I'm building a C ++ project with VS2008. I am trying to replace new / delete / malloc / free etc. What works, that is, my replacements cause.
However, my replacement allocator must be initialized. I have done this so far, defining it as a global variable in the C # pragma init_seg (lib) .cpp file defined inside it.
This worked until recently, when std :: locale started initializing, which called a new one before my allocator initialized. So I nervously moved my global distributor variable to the compiler segment, i.e. #pragma init_seg (compiler).
This worked a bit and I decided to override malloc. Now I get a malloc call in __crtGetStringTypeA_stat in _tmainCRTStartup, which before even global vars in the compiler segment were initialized.
Is it possible to instantiate my variable before running CRT. The only thing I can think of is to rebuild my crt lib and try some ways to insert my initialization code wherever. I suppose there should also be a crt cleanup function?
Is there an easier way to do this and / or something obvious that I'm missing here?
source share