JCL Help:StrAllocSize

From Project JEDI Wiki
Jump to navigationJump to search


Summary

Returns the memory allocated to store the string.


Parameters

Parameters Description
S The string for which to determine the total amount of used memory.


Return Value

The amount of dynamic memory allocated for the string or 0 in the exceptions noted above. Note that, at least in Delphi 5, the result will always be a multiple of 4.


Description

A long string variable is a 4 byte pointer to a dynamically allocated block of memory. This block of memory holds the actual string data, including a NULL character. In addition this block of memory has, at a negative offset, a number of 32 bit values used to manage the string. The StringAllocSize function looks at this negative offset to determine the total amount of dynamic memory reserved to hold the string and management data. Note that this function will always return 0 for string literals, string constants and string variables that are assigned to string constants, but haven't been modified yet. This is not a bug but a result of the way in which Delphi manages string constants.


See Also

StrRefCount


About

Donator

Marcel van Brakel


Notes

This function relies on pseudo-undocumented knowledge and should only be used for debugging purposes.


Contribute to this help topic

This documentation wiki is based on the collaborative effort of Project JEDI users. Your edits are welcome in order to improve documentation quality: edit this page