mpGLTextures should be null

Started by
3 comments, last by shadow12345 20 years, 3 months ago
Here is the code I am using to delete mpGLTextures. mpGlTextures is in fact NULL (I''ve checked using assert and _ASSERTE). I don''t understand why it is trying to delete something that is already NULL. mpGLTextures is set to null in my constructor code. I believe I am having memory problems elsewhere in my program to be honest. Here is the code, does anybody have any ideas?

//	_ASSERTE(mpGLTextures); //Says mpGLTextures is NULL
	
	/*if(mpGLTextures == NULL)	//This also says mpGLTextures is NULL
	{
		trace << "mpGLTextures == NULL" << "\n";
		return;
	}
	*/
	if(mpGLTextures)
	{
		glDeleteTextures(mNumTextures,mpGLTextures);
		if(mpGLTextures)
		{
			delete[]	mpGLTextures;
			mpGLTextures = NULL;
		}
		mNumTextures	=	0;
	}
 
Any help would greatly be appreciated.
Why don't alcoholics make good calculus teachers?Because they don't know their limits!Oh come on, Newton wasn't THAT smart...
Advertisement
have you stepped through it?
Yes, and it tells me that the program is failing here:

if(mpGLTextures)

The thing I do not understand is that if mpGLTextures is null, it should simply not run the if statement, not crash. I am very confused, I am using various things to track the problem i.e crtCheckMemory and assert but I do not know what I am doing wrong. Perhaps I coded something wrong in the destructor? (I didn't post the destructor/constructor code because it is lengthy, but I can post it if I need to).



[edited by - Shadow12345 on February 6, 2004 10:58:39 AM]
Why don't alcoholics make good calculus teachers?Because they don't know their limits!Oh come on, Newton wasn't THAT smart...
Ah, that's something new. You didn't say it was crashing.

Probably the object that this function is called on is invalid. What value is the this pointer?

[edited by - petewood on February 6, 2004 11:07:24 AM]
I''m sorry for being so vague. I believe I have found the problem after you told me to check for the value in the this pointer. It was in fact zero...I was deleting the object and setting it to NULL in one function, but then trying to reload it in another function without calling NEW on it again. I really feel silly right now. i''m still having problems in other areas, but that''s because I need to clean up my memory allocated by some external std::vectors. Thank you for bumping me in the correct direction

I feel silly lol
Why don't alcoholics make good calculus teachers?Because they don't know their limits!Oh come on, Newton wasn't THAT smart...

This topic is closed to new replies.

Advertisement