This code snippet specifies a custom cleanup method for the RImageTypeDescriptionArray. This way it is possible to simply call CleanupStack::PopAndDestroy() in that method on the array and do whatever additional cleanup is needed there.
In this case ResetAndDestroy() is called on the array to release resources consumed by it. In general, creating a custom cleanup method allows the cleanup to be more sophisticated than simply deleting objects, for example, releasing access to a shared resource.
The following capabilities and libraries are required:
void CleanupRArray( TAny* object )
// Create a custom cleanup item and specify CleanupRArray to be the
// method that is called once CleanupStack::PopAndDestroy() is called
CleanupStack::PushL( TCleanupItem(CleanupRArray, &imageTypes) );
// Here is some code that can leave
// This will lead to a call to CleanupRArray, the custom cleanup method.