Sign in to follow this  

Is this a memory leak? [resolved]

This topic is 4356 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[i]) )->Release();
}




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

Share this post


Link to post
Share on other sites
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

This topic is 4356 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this