How to Distroy the object pointer that are taken be new(ELeave)

Login to reply to this topic.
Mon, 2006-05-22 06:16
Joined: 2006-02-15
Forum posts: 38
Hi,

Can any body tell me how a pointer can be destried after it is used, that is created by using new (ELeave).

For example.

CAknInformationNote* note = new (ELeave)  CAknInformationNote;

note->ExecuteLD(*buf);

Now after the execution of note how can I destory the note

Thanks in advance

Mon, 2006-05-22 06:30
Joined: 2005-02-12
Forum posts: 98
Re: How to Distroy the object pointer that are taken be new(ELe
you don't need ..See EXecuteLD ....Last D indicates that after executing note is is also responsible fotr destroying ...See Api Documentation in SDK.
Mon, 2006-05-22 06:39
Joined: 2006-02-15
Forum posts: 38
Re: How to Distroy the object pointer that are taken be new(ELe
Thanks you very much vikas_bansal for your reply.

but how can I distroy other pointers like:
CArrayPtr<CGulIcon>* icons = new(ELeave) CAknIconArray(2);

Thank in advance for you reply again

Mon, 2006-05-22 06:56
Joined: 2006-05-22
Forum posts: 37
Re: How to Distroy the object pointer that are taken be new(ELe
At first you should get familiar with the CleanupStack used in Symbian (please consult the devlib for further information). This is your only garant that your pointers get destroyed in failure case.
If you don't have a class member as in your example you have to destroy the pointer by simply delete it in most cases (and use the cleanupstack if you are doing something that can Leave).
Class members normally destroyed in the destrcutor and you should not use the cleanupstack for them.
For pointer arrays depending on the type you need to call ResetAndDestroy() before deleting the pointer to ensure all members of the array get cleaned as well.

BR

have fun...

Rayko Enz
www.sic-software.com

Tue, 2006-05-23 01:00
Forum Nokia Champion
Joined: 2003-10-01
Forum posts: 723
Re: How to Distroy the object pointer that are taken be new(ELe
Quote from: bashirpk
Thanks you very much vikas_bansal for your reply.

but how can I distroy other pointers like:
CArrayPtr<CGulIcon>* icons = new(ELeave) CAknIconArray(2);

Thank in advance for you reply again

Normally you have to treat these objects as if they had been created simply with new (i.e. without ELeave). That is, call delete on them if you want to destroy them.

Other than that, I agree with rayko_enz that you should use the cleanup stack in most cases.

Tote

Gabor Torok
Software architect, Agil Eight (http://www.agileight.com/)
Blog: http://mobile-thoughts.blogspot.com/

  • Login to reply to this topic.