Skip to content

SetStr

Allocate a copy of a shortstring on the heap.

Declaration

Source position: objects.pp line 674

  procedure SetStr(var p: PString; const s: string);

Description

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.

Errors

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

See also

Name Description
DisposeStr Dispose of a shortstring which was allocated on the heap.
NewStr Allocate a copy of a shortstring on the heap.