Monday, May 09, 2005
Tip 6: Need to read from an HBufC? Don't call Des().
HBufC* bert = KBert.AllocL();
TPtrC halfOfBert = bert->Left(2);
One of the most common mistakes made when using descriptors is to call Des() on an HBufC* when you only need a constant descriptor.
HBufC* bert = KBert().AllocL();
TPtrC halfOfBert = bert->Des().Left(2); // Unnecessary call to Des()
It won’t do any harm, but is totally unnecessary and wastes time, space and typing