struct CUSTOMVERTEX
{
float x, y, z;
float tu, tv;
};
typedef struct tagTRIANGLE
{
CUSTOMVERTEX points[3];
} TRIANGLE;
TRIANGLE * WorldData = NULL;
DWORD dwNumTriangles = 36;
WorldData = (TRIANGLE*)malloc(dwNumTriangles*sizeof(TRIANGLE));
If anybody has any idea why it''s not giving me the correct answer, it would be appreciated if you could tell me why.
Thanks in advance
Problems with malloc
Can somebody please take a look at this. When I run it, and I try to get sizeof(WorldData) I get 4 as a result. On the other hand dwNumTriangles*sizeof(TRIANGLE) seems to be evaluating to the correct answer.
WorldData is a pointer. On a 32bit platform 4 bytes (32bits) are used to store an address. Therefore WorldData is 4 bytes.
[Resist Windows XP''s Invasive Production Activation Technology!]
[Resist Windows XP''s Invasive Production Activation Technology!]
Also, keep in mind that the sizeof() operator is evaluated at *compile* time and not runtime.
-Brannon
-Brannon
If that''s the case, then how would I go about finding the size in bytes of the entire WorldData array?
Store it yourself. Obviously at one point you know it is dwNumTriangles*sizeof(TRIANGLE), so just keep that in a variable somewhere.
[Resist Windows XP''s Invasive Production Activation Technology!]
[Resist Windows XP''s Invasive Production Activation Technology!]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement