• Advertisement
Sign in to follow this  

Is this a memory leak? [resolved]

This topic is 4426 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