Hi All:

I am trying to read the contents of a memory stream into a dynamic array of characters and the program keeps crashing when I try to free the dynamic array.

Really simple code:

  Buf : array of Char;
  Stream : TMemoryStream;
begin

// Initialize Stream here
  SetLength( Buf, Stream.Size );
// do nothing here
  SetLength( Buf, 0 ); // This works

  SetLength( Buf, Stream.Size );
  Stream.Read( Buf ); // or Stream.ReadBuffer( B, Stream.Size );
  SetLength( Buf, 0 ); // This crashes

end;

I've tried passing the Address of Buf, but the compiler doesn't like it.
Does anyone have any ideas how I can work around this?

Thanks,

Don Ziesig

--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to