[fpc-pascal] Effective memory allocation
Nikolay Nikolov
nickysn at gmail.com
Sun Nov 2 19:26:57 CET 2014
On 11/02/2014 03:54 PM, Xiangrong Fang wrote:
> Hi All,
>
> ...
>
> Also, I usually use pointer to pass block of memory to functions. How
> do I implement a function with the following signature:
>
> procedure MyProc(var Buf; Len: Integer):
>
> I mean, how to handle "var Buf" inside the procedure body?
You can take the address of the Buf variable by using @Buf. For example:
procedure MyProc(var Buf; Len: Integer);
var
I: Integer;
P: PByte;
begin
P := @Buf;
for I := 0 to Len - 1 do
(P+I)^ := 0;
end;
Nikolay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20141102/5f9988da/attachment.html>
More information about the fpc-pascal
mailing list