Full size Banner

Inside Symbian OS CleanUpStack

When a function leaves, it transfers control directly to the statement following the TRAP (or TRAPD) macro under which it was invoked. This is carried out by setting the stack pointer to the context of the original TRAP macro, and jumping to the desired program location.
Create your own CleanUpStack for each thread. We need CleanUpStack if we do something with memory. If we don't do anything with memory then we don't need CleanUpStack at all. Each thread need to create it's own CleanUpStack by the following code. For GUI application we don't need to create CleanUpStack by ourselves since it is created by the GUI framework.
GLDEF_C TInt E32Main()
{
__UHEAP_MARK;
CTrapCleanup* cleanup=CTrapCleanup::New();
...