Saturday, May 14, 2005

15. What is the memory layout of pointer descriptors? How much memory do they occupy besides the data itself?

Since pointer descriptors all derive from TDesC (either directly for constant pointer descriptors or from TDes, for modifiable descriptors), the first 4 bytes are used to store the current length of the descriptor data.

In a constant pointer descriptor (TPtrC), a 4-byte pointer to the data follows the length word, thus the total size of the descriptor object is two words (8 bytes).

In a modifiable pointer descriptor (TPtr) which derives from TDes, the maximum data length word follows the current length, which is then followed by the data pointer. Thus, the descriptor object is three words in length (12 bytes).


You can find some diagrams which illustrate this in [reference 4].

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

Google
WWW Descriptors FAQ