Thursday, January 14, 2016

How to determine the memory allocation is successful




            


I used HBufC8 * buf = HBufC8 :: NewL (KMaxFileName);
Such methods may I ask how to judge whether to allocate buf success? Thank you
Reply:
Leave the assignment will not succeed ^ _ ^
Reply:
what do you mean? They are given on the phone if there is such a situation is not usually pop insufficient memory?
Reply:
Trap, TrapD, can capture Leave.

TInt E32Main ()
{
testConsole.Title (); // write out title
testConsole.Start (_LIT ("Example")); // start a new "test"

// The leave variable
TInt r;
// Perform example function. If it leaves,
// The leave code is put in r
TRAP (r, doExampleL ());
// Test the leave variable
if (r)
testConsole.Printf (_LIT ("Failed: leave code =% d"), r);

testConsole.End (); // finish
testConsole.Close (); // close it
return KErrNone; // and return
}

No comments:

Post a Comment