Panic USER 8 after append data two times in HBufC reallocated Descriptor.

Login to reply to this topic.
Sat, 2007-08-18 15:57
Joined: 2007-06-27
Forum posts: 25

Get Panic USER-8 when i=2 that data not copy into the descriptor.
and i reallocated descriptor with 14 also look following

my String is: "Abcdef M"
Array Count is: 5
like:
Abcdef = 7 ----> i=0
< 7+1 = 8 ----> i=1
ghijkl 8+6 = 14 ---> i=2

i Get string only: "Abcdef <"
i check at debug time first of all reallocate with 8 (Total Len: Abcdef <)

please check my code and tell me my mistake. i am very Confused that where is the problem!!!! please you can help me pleeeeeeeeeese.............

void CArrayHandler::EndElement(const TDesC& aElemName)
{

HBufC* log = HBufC::NewLC(aElemName.Length() + 8);
log->Des().Copy( aElemName );
if(log->Des().Compare(KColTag()) == 0)
{

TInt arrEleCount = 0;
TPtrC name;
arrEleCount = iColumnData->MdcaCount();
if(arrEleCount>0)
{

TInt i = 0;
TInt newLen = 0;
TInt newEleLen = 0;
TInt elementLen = 0;
TInt temp = 0;

elementLen = ( (*iColumnData)[0] ).Length();
HBufC* coldata = HBufC::NewLC(elementLen);

for( i=0 ; i {

coldata->Des().Append( (*iColumnData)[i] );
name.Set(coldata->Des());
newLen = coldata->Des().Length();
TInt loop;
loop = i;
if( loop != arrEleCount)
{

elementLen = ( (*iColumnData)[loop+1] ).Length();
TInt newEleLen = 0;
newEleLen = newLen + elementLen;
coldata->ReAllocL(newEleLen);

}

}
WriteFile(*coldata);
CleanupStack::PopAndDestroy();
delete iColumnData;
iColumnData = NULL;

} // end if arrEleCount

}
CleanupStack::PopAndDestroy();

}
Tanya


Sat, 2007-08-18 19:00
Joined: 2006-05-08
Forum posts: 162
Re: Panic USER 8 after append data two times in HBufC reallocate

Dear SymbianTG,

There are other issues, besides just the panic. One by one:

1. Please read the Symbian OS documentation on the panic code. Here's what it says:
This panic is raised when a length value passed to a 16-bit variant descriptor member function is invalid. It may be raised by some descriptor constructors and, specifically, by the Replace() and Set() descriptor member functions. That should give you a good hint as to where things are getting wrong...

2. Don't use HBuf! See this for descriptor usage guides.

3. The EndElement method signature suggests its non leaving, however, you are calling leaving functions inside and NOT even bothering to push objects into the cleanup stack. Very messy!

4. The EndElement method can be optimised and re-written to be more readable. You seem to be allocating and creating variables when they are not needed.

Finally, what on earth is your function trying to achive? It looks like it can be solved in a lot better way...


  • Login to reply to this topic.