Win32 API Memory Leak

Oct 29, 2009 at 10:00pm
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?
Oct 29, 2009 at 10:28pm
closed account (z05DSL3A)
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.
Oct 29, 2009 at 10:31pm
Good idea. I'll do that.
Topic archived. No new replies allowed.