I am affraid that it is incorrect. The code above has worked in production for ~ 10 years for a smaller structure.
The purpose of the macro MY_TYPE is to translate the type of a member of the structure into the argument of the function SetType(...). In real life there are a bunch of overloading functions SetType(...) with different types of argument, and the union MY_UNION represents all possible types. I believe that the difference for smaller and bigger structure is more understanble when you look at the Assembly code but I still cannot completely explain it.
Thanks.
Main Topics
Browse All Topics





by: rpzPosted on 2004-08-01 at 03:22:17ID: 11687294
You're typecasting a 4 byte variable into a 18 kb struct and returning the last member? That would put you about 18247 bytes beyond what you allocated memory for. I guess you hit a valid pointer by accident when commenting out parts of the struct. What is the purpose of this code exactly?