Descriptors

It is possible to present and read different kinds of information from the user interface. Symbian OS provides built-in data types for most string formats that can then be passed as parameters to functions, objects, and macros. Though these data types are actually descriptors that automatically fix many problems with normal C-style strings (like null-termination and orphaning), their length can vary depending on content. A related concern is miscalculating the length of a descriptor, which can lead to data truncation or increased memory consumption.

There are modifiable and nonmodifiable (trailing "C" in class name) descriptors. The length of a nonmodifiable descriptor is defined when compiling an application, and the length of a modifiable descriptor can vary within the limits set by iMaxLength. In general, nonmodifiable descriptors are more secure, as their length is checked during compilation. The following figure shows the differences between these types.

Figure 24: Differences between modifiable, nonmodifiable, and pointer descriptors

When designing applications, use of fixed-length buffers as parameters should be avoided and base classes (preferably constant base type TDesC*) used instead. Descriptor objects provide a flexible interface for manipulating the containing string, including size and length checks. These should be taken advantage of when possible. See the Forum Nokia S60 Platform: Descriptor Example for details.