post  Win32 API Memory Leak

Lamblion (149)   Link to this post
I have an application with four main tabs. I am encountering a 4k memory leak on about every sixth to eighth tab change. Not much, I know, but it's bugging me. The ONLY place I can figure the leak is in the following code, although I can't for the life of me see how the following code could be causing the leak. Is this code leaking memory...

1
2
3
4
5
6
7
if(NULL != hAccel)
	{
		DestroyAcceleratorTable(hAccel);
		hAccel=NULL;
	}

	hAccel = LoadAccelerators(hBOSSInst, MAKEINTRESOURCE(IDR_VLO_ACCEL));


Or are there some memory gremlins lurking about that I can't see?
Grey Wolf (1407)   Link to this post
You should check the return from DestroyAcceleratorTable() before nulling hAccel.
It will return nonzero if it succeeds and zero on failure. It will fail if CreateAcceleratorTable or LoadAccelerators function are called more than once.
Lamblion (149)   Link to this post
Good idea. I'll do that.

Registered users can post in this forum.