[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'Objects' (#rtl)


Allocate a copy of a shortstring on the heap.


Source position: objects.pp line 637

procedure SetStr(

  var p: PString;

  const s: string



SetStr makes a copy of the string S on the heap and returns the pointer to this copy in P. If P pointed to another string (i.e. was not Nil, the memory is released first. Contrary to NewStr, if the string is empty then a pointer to an empty string is returned.

The allocated memory is not based on the declared size of the string passed to NewStr, but is based on the actual length of the string.


If not enough memory is available, an 'out of memory' error will occur.

See also



Dispose of a shortstring which was allocated on the heap.



Allocate a copy of a shortstring on the heap.

Documentation generated on: May 14 2021