{ Heap Strings handling unit }

unit Strings;

interface

type
  { String pointers }
  PString = ^String;

  { Dynamic string handling routines }
  function NewStr(const S: String): PString;
  procedure DisposeStr(P: PString);

implementation

{ Dynamic string handling routines }

function NewStr(const S: String): PString;
var
  P: PString;
begin
  if S = '' then P := nil else
  begin
    GetMem(P, Length(S) + 1);
    P^ := S;
  end;
  NewStr := P;
end;

procedure DisposeStr(P: PString);
begin
  if P <> nil then FreeMem(P, Length(P^) + 1);
end;

end.