Care use ATL X2X string to convert macro

zhaozj2021-02-16  50

Everyone may feel that a series of macros in the W2T, T2W in ATL is very convenient, but must be careful because:

They allocate memory from the stack !!! The internal calls alloca, which allocates the memory of the string from the stack, and until it comes to the function returns before returning, the memory will not be released.

If this kind of macro is called tens of thousands of times you repeatedly, you will inevitably generate Stack Overflow! ! This situation seems to be normal when the number of cycles is not large, and the number will be alive.

The solution is that the statement that will be used to use the macro is independently encapsulated into a function.

转载请注明原文地址:https://www.9cbs.com/read-25566.html

New Post(0)