Location:
e32base.h
Link against: euser.lib
CleanupStack
Supported from 5.0
A collection of static functions that are used to add resources to and remove resources from the cleanup stack.
Defined in CleanupStack
:
Pop()
, PopAndDestroy()
, PushL()
static void PushL(TAny* aPtr);
static void PushL(CBase* aPtr);
static void PushL(TCleanupItem anItem);
Pushes a pointer to an object onto the cleanup stack. Use the
function PushL(TCleanupItem anItem)
to push a cleanup item onto
the cleanup stack.
If a leave occurs while an object is on the stack, it is cleaned up automatically:
CBase
-derived objects are cleaned up with
delete
.
Untyped objects are cleaned up with
User::Free()
(a rather limited form of cleanup — not
even the C++ destructor is called).
Typically, when an object has been fully constructed and it can
be guaranteed that a pointer to this new object is stored in some other object
before a leave occurs, issue CleanupStack::Pop()
to pop it back
off the stack.
If a leave occurs while a cleanup item is on the stack, the
cleanup operation defined in the construction of the TCleanupItem
,
is invoked.
Like CBase*
and TAny*
types, cleanup
items can also be popped back off the stack by calling
CleanupStack::Pop()
.
If no cleanup stack has been allocated, a panic occurs.
Note that for any thread, calling PushL()
when no prior call to TRAP
has been made, raises an E32USER-CBase 66 panic.
|
|
static void Pop();
static void Pop(TInt aCount);
Pops an object previously pushed onto the cleanup stack by
CleanupStack::PushL()
.
After an object has been successfully constructed and stored within another object, it cannot be orphaned and, therefore, the object (i.e. a pointer or a cleanup item) can be popped from the cleanup stack.
The second version of the function allows a specified number
(aCount
) of objects to be popped off the cleanup stack.
If no cleanup stack has been allocated, or there is nothing on the stack, a panic occurs.
|
static void PopAndDestroy();
static void PopAndDestroy(TInt aCount);
Pops and cleans up an item pushed onto the stack.
If the item on the stack is a CBase*
pointer, the
pointer is removed from the stack and the object is destroyed with
delete
.
If the item on the stack is a TAny*
pointer, the
pointer is removed from the stack and the memory occupied by the object is
freed with User::Free()
.
If the item on the stack is a cleanup item, i.e. an object of type
TCleanupItem
, the item is removed from the stack and the cleanup
operation defined during construction of the TCleanupItem
object
is invoked.
Similar to Pop()
, the second version of the function
allows a specified number (aCount
) of objects to be popped off the
cleanup stack and cleaned up.
If no cleanup stack has been allocated, or there is nothing on the stack, a panic occurs.