quote:
From the tutorial
Say we want to load the glCommands variable, well, here is how we''d go about doing it:
glCommands= new long [header.numGlCommands*sizeof(long)];
Demonstration code :
Type *pMem = new Type[nItems];
In this piece of code, ''new'' allocates memory enough for
nItems of type
Type . That means it is equivalent to a such a call to malloc :
Type *pMem = (Type*) malloc(nItems * sizeof(Type));
Thus, NeHe''s code allocates
n times the memory needed for the glCommands (where
n is the sizeof(long)). This means there''s some wasted space.
I believe it should be :
glCommands = new long[header.numGlCommands];
It works fine this way.
Thanks (I''m sorry if someone said this before, I just made a search on the board and didn''t find any relevant threads)