Long string dynamic memory layout (Win32 only) Offset Contents -8
32-bit reference-count
-4
length in bytes
0..Length - 1 character string
Length NULL character
The NULL character at the end of a long string memory block is automatically maintained by the compiler and the
built-in string handling routines. This makes it possible to typecast a long string directly to a null-terminated string.
For string constants and literals, the compiler generates a memory block with the same layout as a dynamically
allocated string, but with a reference count of -1. When a long string variable is assigned a string constant, the string
pointer is assigned the address of the memory block generated for the string constant. The built-in string handling
routines know not to attempt to modify blocks that have a reference count of -1.
Note: On the .NET platform, an AnsiString is implemented as an array of unsigned bytes. The information above
on string constants and literals does not apply to the .NET platform.