The cleanup utility functions offer easy ways of constructing a TCleanUpItem and pushing it onto the cleanup stack. They support three types of clean up operation:
where the object is deleted: template <class T>
void CleanupDeletePushL(T*)
where the object's Close() member function is called: template <class T>
void CleanupClosePushL(T&)
where the object's Release() member function is called: template <class T>
void CleanupReleasePushL(T&)
The functions have three supporting templated classes:
CleanupDelete<class T>
CleanupClose<class T>
CleanupRelease<class T>
The way in which these work is best illustrated graphically by taking CleanupClosePushL() as an example. See the diagram below.

Effect of CleanupClosePushL and subsequent pop and destroy