unit default_allocator;

{$MODE FPC}
{$MODESWITCH DEFAULTPARAMETERS}
{$MODESWITCH OUT}
{$MODESWITCH RESULT}

interface

type
TDefaultAllocator = object
public type
  TInitializer = record end;
public const
  DefaultInitializer: TInitializer = ();
public
  procedure Init(Initializer: TInitializer); static;
  procedure Done; static;
  procedure GetMem(out P: Pointer; Size: SizeUInt); static;
  procedure FreeMem(P: Pointer); static;
  function ReallocMem(var P: Pointer; Size: SizeUInt): Pointer; static;
end;

implementation

procedure TDefaultAllocator.Init(Initializer: TInitializer);
begin
end;

procedure TDefaultAllocator.Done;
begin
end;

procedure TDefaultAllocator.GetMem(out P: Pointer; Size: SizeUInt);
begin
  System.GetMem(P, Size);
end;

procedure TDefaultAllocator.FreeMem(P: Pointer);
begin
  System.FreeMem(P);
end;

function TDefaultAllocator.ReallocMem(var P: Pointer; Size: SizeUInt): Pointer;
begin
  Exit(System.ReallocMem(P, Size));
end;

end.
