Monday, May 09, 2005

 

Tip 2: Check that there is sufficient space before writing to a descriptor

An attempt to access an area outside the area allocated for descriptor data will cause a panic in both debug and release builds, because the descriptor functions use __ASSERT_ALWAYS to check for out-of-bounds access. A panic causes your code will stop executing immediately, whether running in an application, server or test framework. So be absolutely certain that there is space in your target descriptor, if necessary, by doing a check first by using the Length() or MaxLength() methods.

_LIT8(KImageGif, “image/gif”); // 9 characters
TBuf8<8> mimeType8; // Space for only 8 characters

mimeType8.Copy(KImageGif); // Panic!

Comments:
Or, if no error checking is needed:

_LIT8(KImageGif, “image/gif”); // 9 characters
TBuf8<8> mimeType8; // Space for only 8 characters
mimeType8.Copy(KImageGif().Left(mimeType9.MaxLength()));
 
mimeType9 ? 9 or 8 ?
 
I think that's a typo. Should be mimeType8.

Thanks, both of you (?) for your comments. I do value your feedback. In future, I'd prefer not to receive anonymous comments; if possible, please can you leave a name.
 
helpful tips and Very useful and important for all bloggers.I managed to create health related site you must like it
 
Investment Plans to make money online, Online Jobs can make money online from home, Just Visit
www.jobzcorner.com
 
"Free Social Media Marketing where Every thing will be Free, Facebook Likes, Twitter Followers, Twitter Tweets, Twitter Re-Tweets, Twitter Favorites, Google Plus Followers, StumbleUpon Followers, Youtube Views, Youtube Likes, Youtube Subsribes, Pinterest Followers, Pinterest Likes, Pinterest PinIt, Free Website Visitors."
Just Join now and Free Increase your Social Media Networks.
GetLikeFast.com

 
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?

Google
WWW Top Tips for Descriptors