Home » U++ Library support » U++ Core » what is the largest Array size please? ("out of memory" error)
Re: what is the largest Array size please? ("out of memory" error) [message #15032 is a reply to message #15027] |
Wed, 26 March 2008 14:04   |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
double Get(int nCol,int nRow){if(nRow>=0 && nCol>=0 && nRow<m_nRows && nCol<m_nCols)return m_ppData[nRow][nCol];}
void Set(int nCol,int nRow,double val){if(nRow>=0 && nCol>=0 && nRow<m_nRows && nCol<m_nCols)m_ppData[nRow][nCol]=val;}
If the array structure is [double*(columns)][double(rows)] then you have these backwards. If row count and column count are different Set will always write outside of the array on a copy op since you have this code:
// copy values
for(int i=0;i<grid.m_nCols;i++)
{
// memcpy(m_ppData[i], grid.GetCol(i), m_nRows * sizeof(double));
for(int j=0;j<m_nRows;j++)
{
this->Set(i,j,grid.m_ppData[i][j]);
}
}
Additionally I believe the loop is redundant since you've just copied all the data with memcpy.
Edit: also I believe the delete calls in the contructor should be delete[]
James
[Updated on: Wed, 26 March 2008 16:11] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Tue Jul 08 14:11:02 CEST 2025
Total time taken to generate the page: 0.03518 seconds
|