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

SetStr

Allocate a copy of a shortstring on the heap.

Declaration

Source position: objects.pp line 629

procedure SetStr(

  var p: PString;

  const s: String

);

Description

SetStrmakes a copy of the string Son the heap and returns the pointer to this copy in P. If Ppointed 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.

Errors

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

See also

DisposeStr

  

Dispose of a shortstring which was allocated on the heap.

NewStr

  

Allocate a copy of a shortstring on the heap.