[fpc-devel] Readonly Memory Stream?
    LacaK 
    lacak at zoznam.sk
       
    Wed Feb 13 10:40:10 CET 2019
    
    
  
Hi,
sometimes I have to work with static fixed buffer in memory (for example
returned from external API), which I would like to behave like stream.
Then I define:
type TStaticMemoryStream = class(TCustomMemoryStream) end;
and in code I use for example:
    MS := TStaticMemoryStream.Create;
    MS.SetPointer(buffer, bufferLen);
    MS.Position := 0;
    Bitmap.LoadFromStream(MS);
    MS.Free;
I know that it is only very few lines of code, but would it we worth to
extend capability of TMemoryStream in RTL to support for example
constructor like:
  TMemoryStream.Create(buffer, bufferLen);
which will instantiate memory stream on fixed memory block without
possibility to Write?
Or introduce new TCustomMemoryStream descendant in RTL like my
TStaticMemoryStream() ?
Only question...
TIA
-Laco.
    
    
More information about the fpc-devel
mailing list