uses
  dsmallbufferoptimization,
  dsbo;

var
  Buf: array[0 .. 32 - 1] of Byte;
  SmallBuffer: TSmallBufferHolder;
  Data: Pointer;

procedure PrintBuffer(Data: Pointer; S: SizeUInt);
var
  I: SizeUInt;
begin
  for I := 0 to S - 1 do
    Write(PAnsiChar(Data)[I]);
  Writeln;
end;

begin
  SmallBuffer.Init(Buf, 10);
  Move(PAnsiChar('abcdefghjk')^, SmallBuffer.Data^, 10);
  Writeln(SmallBuffer.InHeap);
  PrintBuffer(SmallBuffer.Data, 10);
  SmallBuffer.ReAllocate(64);
  Move(PAnsiChar('ABCDEFGHJK')^, (SmallBuffer.Data + 10)^, 10);
  Writeln(SmallBuffer.InHeap);
  PrintBuffer(SmallBuffer.Data, 20);
  SmallBuffer.Done;

  Data := SBOGetMem(Buf, 10);
  Move(PAnsiChar('abcdefghjk')^, Data^, 10);
  PrintBuffer(Data, 10);
  Data := SBOReAllocMem(Buf, Data, 64);
  Move(PAnsiChar('ABCDEFGHJK')^, (Data + 10)^, 10);
  PrintBuffer(Data, 20);
  SBOFreeMem(Buf, Data);
end.
