[fpc-devel] TBytes

Martin Schreiber mse00000 at gmail.com
Tue Feb 28 09:49:31 CET 2012


Am 28.02.2012 10:38, schrieb Marco van de Voort:
> In our previous episode, Martin Schreiber said:
>> I read that we should use TBytes instead of AnsiString in order to
>> implement combined binary/character buffers with automatic memory
>> management. With AnsiString we used setlength() in order to allocate not
>> initialized  memory.
>> TBytes is defined as
>> "
>>      TBytes = array of Byte;
>> "
>> where setlength() fills the buffer with zeros. What should we use instead?
>
> If you care, you can do manual management.

Yup, MSEgui has allocuninitedarray() for the purpose. I don't think it 
is more "clean" or "secure" than the old ansistring method because it 
depends on compiler internals.

> Or pool arrays of byte. (I do
> this in my Delphi app, where I have a nice generic pool class).
>
I like handy tools. Using FPC 2.6 AnsiString as buffer is handy.

> But I don't think TBookmark is very speed-sensitive.

We don't talk about TBookmark only here. AFAIK all "string as 
databuffer" is prohibited in future FPC.

Martin



More information about the fpc-devel mailing list