Name: Anonymous 2008-10-22 15:48
So it seems I don't know how to use delete properly in C++. I have a "Matrix" class that dynamically allocates memory for a 2D array of floats, and I'm creating and destroying tonnes of these as the application runs. So I put this in the destructor.
It crashes instantly.
Here is the matrix variable:
And here is the code setting up the matrix:
Wtf is my stupid ass doing wrong?
for(GLuint i = 0 ; i < height ; i++)
delete matrix[i];It crashes instantly.
Here is the matrix variable:
GLfloat **matrix;And here is the code setting up the matrix:
matrix = new GLfloat*[height];
for(GLuint i = 0 ; i < height ; i++){
matrix[i] = new GLfloat[width];
for(GLuint j = 0 ; j < width ; j++){
matrix[i][j] = (i == j && isIdentity ? 1 : 0 );
}
}Wtf is my stupid ass doing wrong?