This code snippet releases memory and closes all open handles, files, etc. before exiting a function. Even if a function has to return, for whatever reason, this code ensures all resources remain released.
The code, which is written in a function, is written in the __try & __finally block.
Here is small example:
#define MYCONSTANT "OK THIS IS A TEST"
int a = 0;
char* ptrMem = new char;
printf("Enter a number : - ");
if(0 == (a%2))
//some problem, required to quit
//No problem do the required operations
//and delete the memory
if(NULL != ptrMem)
delete  ptrMem;
ptrMem = NULL;
The __try and __finally blocks take care that at any time the function returns, it deallocates the allocated memory. This block is very important, for releasing all the allocated resources, hence making sure that all the resources are properly deallocated&meaning, no more memory leaks, open handles, etc.