Jump to content
  • Advertisement
Sign in to follow this  
Sk1d_Row

Is this a memory leak? [resolved]

This topic is 4605 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Assume the 2 functions are called in appropiate order...and the non-declared variables are global...

std::vector<LPDIRECT3DTEXTURE9*> textures;

void LoadTexture(char* filename)
{
	LPDIRECT3DTEXTURE9* temp = new LPDIRECT3DTEXTURE9;

	if(FAILED (D3DXCreateTextureFromFile(	d3d_device, 
						filename, 
						temp) ) )
	{
		assert(0);
	}

	textures.push_back(temp);
}

void shutdown()
{
     for(unsigned i = 0; i < textures.size(); ++i)
		(*(textures) )->Release();
}




[Edited by - Sk1d_Row on January 8, 2006 11:02:43 PM]

Share this post


Link to post
Share on other sites
Advertisement
Yes, it is. There is no need to do the 'new LPDIRECT3DTEXTURE9'. All you need is something like this:

LPDIRECT3DTEXTURE9 temp;

if(FAILED (D3DXCreateTextureFromFile(d3d_device,
filename,
&temp)))
...

And declare your vector as:

std::vector<LPDIRECT3DTEXTURE9> textures;

(assuming it's a vector).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!