title: LZO Compression - How set the destination length?
body: <p>I'm trying use lzo.dll to compress some file, my code(Delphi) is that:</p>
  
  <pre><code>function lzo2a_999_compress(const Source: Pointer; SourceLength: LongWord; Dest: Pointer; var DestLength: LongWord; WorkMem: Pointer): Integer; cdecl; external 'lzo.dll';
  ...
  function LZO_compress(FileInput, FileOutput: String): Integer;
  var
     FInput, FOutput: TMemoryStream;
     WorkMem: Pointer;
     Buffer: TBytes;
     OutputLength: LongWord;
  begin
     FInput := TMemoryStream.Create;
     FOutput := TMemoryStream.Create;
     FInput.LoadFromFile(FileInput);
     FInput.Position := 0;
     GetMem(WorkMem, 1000000);
     OutputLength := ??!?!?!;
     SetLength(Buffer, OutputLength);
     try
        lzo2a_999_compress(FInput.Memory, FInput.Size, Buffer, OutputLength, WorkMem);
     finally
        FOutput.CopyFrom(Buffer, Length(Buffer));
     end;
     FOutput.SaveToFile(FileOutput);
     FreeMem(WorkMem, 1000000);
     FInput.Free;
     FOutput.Free;
  end;
  ...
  </code></pre>
  
  <p>The problem is: how set the "OutputLength"? I can allocate a huge size to prevent problems but the FOutput will be the same size of the Buffer. How can I save only the compressed data on OutputFile?
  Thanks in advance.</p>