[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] |
Allocate a copy of a shortstring on the heap.
Source position: objects.pp line 620
function NewStr( |
const S: String |
):PString; |
NewStr makes a copy of the string S on the heap, and returns a pointer to this copy. If the string is empty then Nil is returned.
The allocated memory is not based on the declared size of the string passed to NewStr, but is baed on the actual length of the string.
If not enough memory is available, an 'out of memory' error will occur.
|
Dispose of a shortstring which was allocated on the heap. |
|
|
Allocate a copy of a shortstring on the heap. |
Program ex40; { Program to demonstrate the NewStr function } Uses Objects; Var S : String; P : PString; begin S:='Some really cute string'; P:=NewStr(S); If P^<>S then Writeln ('Oh-oh... Something is wrong !!'); DisposeStr(P); end.
lazarus-ccr.sourceforge.net |