I'm running tests to see how variables are getting placed on the memory and sizing them out when I use a struct. Consider I have a struct that looks like below:
typedef struct _ttmp
{
WCHAR wcsTest1[13];
WCHAR wcsTest2[13];
wstring wstr;
}TTMP, *LPTTMP;
How big is the size of TTMP
when STL classes like wstring
are dynamically allocated?
Am I treating wstr
as a 4-byte pointer?
I ran some tests to see the size of TTMP
and got the size of the struct to be 88-bytes
and two of WCHAR
arrays were 26-bytes
which leaves the size of wstr to be 36-bytes
, but that 36-bytes
does not really make sense if I were to treat the wstring as a pointer. Seems like alignment padding does not apply here since I'm only using 32-bit variables.
Also, would it be bad a practice to use ZeroMemory
api on structs with STL?
I've heard from someone that it is not safe to use the api, but the program ran fine when I test it