This smells remarkably like a school assignment.  Why would you want to do
this sort of thing many times in real life since testing what touches your
memory block is probably more efficient?

John Dammeyer



Wireless CAN with the CANRF module now available.
http://www.autoartisans.com/products
Automation Artisans Inc.
Ph. 1 250 544 4950


> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Ross Levis
> Sent: Thursday, November 03, 2005 2:54 AM
> To: Delphi Discussion List
> Subject: Test memory block
> 
> 
> I'm looking for the fastest way to test if a block of memory is all 
> zeros or not.  This needs to be as fast as possible since it is being 
> tested many times a second.
> 
> The memory block can be any length.  Assuming Buffer is a 
> pointer to a 
> block of memory, and BufferSize is the length of the block, I'm 
> currently doing it like this.
> 
> type
>   TBufferArray = array[0..0] of Byte;
>   PBufferArray = ^TBufferArray;
> ....
>   var
>      BufArray: BufferArray;
>      i: Integer;
>   begin
>     BufArray := Buffer;
>     Result := False;
>     for i := 0 to BufferSize-1 do
>       if Buffer[i] <> 0 then Exit;
>     Result := True;
> 
> 
> This is reasonably quick but I'm wondering if there is a 
> faster way that 
> does not need to increment an integer many times.
> 
> Thanks,
> Ross. 
> 
> _______________________________________________
> Delphi mailing list -> [email protected]
> http://www.elists.org/mailman/listinfo/delphi
> 
> 

_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to