I have some really weird crash here, ive got it before, but i thought i fixed it by adding = NULL to the variable declarations:
#include <stdlib.h>
...
GLuint *TEX = NULL;
int TEX_MEMSIZE = sizeof(GLuint)*1024*1024;
...
void something1(){
...
TEX = (GLuint *)malloc(TEX_MEMSIZE);
...
}
void something2(){
...
// this line runs fine.
if(TEX != NULL){ // CRASH ON THIS LINE OF CODE
// wont run anything after the above line.
free(TEX);
}
// ...nor here since it crashed...
...
}
It crashes on my laptop/vista, but not on my desktop computer/winXP.
When i remove that if check and the free(), it wont crash anymore.
I just dont get it, what im doing wrong? What could cause this? i only know incorrectly predefined arrays can cause some illogical errors, i dont believe there is such incorrect arrays in my code now, so im waiting for more ideas. (and because checking 20k lines of codes can be quite slow too)
Edit: Now i noticed it will not crash before free() but AFTER it. I start thinking its some predefined array problem... since the position of crash is changing. (or i just have dementia).
EDIT 2: FIXED, there was two free() calls, before and after malloc() >_> i feel so stupid now.