The source descriptor is a literal which is converted to descriptor
type.

To allow more than 15 characters or data items to be assigned into the
heap descriptor, it must be reallocated:

buf = buf->ReAllocL(20);

This permits the following assignment to be done without raising a
panic:

_LIT(KNewText,"Hello World! Morning");
...
*buf = KNewText;

buf may or may not point to a different location in the
heap after reallocation. The location of the reallocated descriptor depends on
the heap fragmentation and the size of the new cell. It is always safer to
assume that the location changes.

Changing data through a modifiable pointer descriptor.

The data contained by a heap descriptor can be changed by
constructing a TPtr modifiable pointer descriptor using the
Des() member function and then changing the data through that
TPtr.

The maximum length of the TPtr is determined from the size
of the cell allocated to the data area of the heap descriptor.

The following code fragment changes the data in the heap descriptor and
the length of the heap descriptor.

Take particular care if a the heap descriptor is re-allocated after the
TPtr has been constructed. A TPtr created before
re-allocating the heap descriptor is not guaranteed to have a valid pointer
after re-allocation. Any attempt to modify data through the original
TPtr after re-allocation may have undefined consequences.

Note: it is a common error to use

Des() to create a
TDesC& reference. While not incorrect, it is simpler and much
more efficient to simply dereference the heap descriptor.