TPtr8 issue ....

Login to reply to this topic.
Thu, 2007-10-11 08:15
Joined: 2007-04-09
Forum posts: 28

Descriptor Issue..
Please help Sad

TUint8* aDst;
aDst = (TUint8*) User::Alloc(320*sizeof(TUint8));
TPtr8 lData(aDst,320);
lData.Set(aDst,320,320);
for()
{
....
//some code is there
lRetVal = fptr.Write(lData,aDstLen);
}
fptr.Close();
fsession.Close();
delete aDst;
aDst = NULL;
lData.Set(aDst2,0,0);

After this also when the application crashes it shows memory leak.
TPtr8 lData is still seems to point to the previous memory location hence i face the crash
.
Is there any way to resolve it.


Thu, 2007-10-11 09:35
Joined: 2003-12-05
Forum posts: 672
Re: TPtr8 issue ....

At least you should use User::Free with User::Alloc, not delete.

Thu, 2007-10-11 15:19
Joined: 2007-04-09
Forum posts: 28
Re: TPtr8 issue ....

Thanks for the advice.
I have used that also
Its just that i have not copied that code.
Rather it should be

//For allocation
TUint8* buffer = (TUint8*)User::Alloc(160*sizeof(TInt16));
//For removal or for freeing allocated memory.
User::Free(buffer);

Fri, 2007-10-12 14:55
Joined: 2004-11-29
Forum posts: 1233
Re: TPtr8 issue ....

There is nothing wrong in the code you have posted (as long as you really use "User::Free" and not "delete" )

Your problem must be in some of the code that you have not posted.

Mon, 2007-10-15 04:16
Joined: 2007-04-09
Forum posts: 28
Re: TPtr8 issue ....

Thanks a lot.
Yes i rectified the problem.
It was in other piece of code....
Smiling

  • Login to reply to this topic.