Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

I suck at delete

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.


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?

Name: Anonymous 2008-10-22 23:05

Fuck GJS, use Julie.

I am not kidding.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List