[Lazarus] Copy buffer of PWord to TMemoryStream

Sven Barth pascaldragon at googlemail.com
Sun Mar 24 19:21:49 CET 2013


On 24.03.2013 19:19, Joao Morais wrote:
> 2013/3/24 Leonardo M. Ramé <l.rame at griensu.com>:
>> Hi, I'm copying a buffer of PWord to a TMemoryStream using this code:
>>
>> lTmpBuff := lBuffer;
>> I := 0;
>> while I < lBufSize do
>> begin
>>    lStream.Write(lTmpBuff^, SizeOf(PWord));
>>    inc(lTmpBuff, 1);
>>    inc(I, 1);
>
> What about:
>
>     inc(lTmpBuff, SizeOf(PWord));
>     inc(I, SizeOf(PWord));

If lTmpBuff is declared as PWord then "Inc" already increases in 
multiplies of "SizeOf(PWord)".
Regarding lBufSize it will be important to know whether the C code 
returns the size in elements or in byte.

Regards,
Sven





More information about the Lazarus mailing list