I get an access violation when running the Debug version of the following code (MFC VC++ 4.0). The Release version runs through with no apparent problems. Help as to how to write it properly and avoid the Access Violation (which occurs in processing the last line). Please email all help to [email protected].
The Code:


struct S_LeagueDirType *p_LeagueList;


unsigned int length = m_MaxLeagueCoord + 1;
delete [] p_LeagueList;
p_LeagueList = new struct S_LeagueDirType [length];