Hi,
In TDbf I use MemScan, which is defined as such: (FPC_DISABLE for testing,
normally FPC)
<code>
{$ifdef FPC_DISABLE}
function MemScan(const Buffer: Pointer; Chr: Byte; Length: Integer): Pointer;
var
I: Integer;
begin
I := System.IndexByte(Buffer, Length, Chr);
if I = -1 then
Result := nil
else
Result := Buffer+I;
end;
{$else}
function MemScan(const Buffer: Pointer; Chr: Byte; Length: Integer): Pointer;
asm
PUSH EDI
MOV EDI,Buffer
MOV AL, Chr
MOV ECX,Length
REPNE SCASB
MOV EAX,0
JNE @@1
MOV EAX,EDI
DEC EAX
@@1: POP EDI
end;
{$endif}
</code>
So you see, it's IndexByte with a tweak. If I'm using the FPC version,
implemented using IndexByte Valgrind reports a lot of errors like so:
==13664== 44439 errors in context 34 of 34:
==13664== Conditional jump or move depends on uninitialised value(s)
==13664== at 0x80537C9: SYSTEM_INDEXBYTE$formal$LONGINT$BYTE$$LONGINT
(i386.inc:312)
==13664== by 0x81C3B28: DBF_COMMON_MEMSCAN$POINTER$BYTE$LONGINT$$POINTER
(dbf_common.pas:433)
==13664== by 0x81E51C2: DBF_MEMO_TMEMOFILE_$__READMEMO$LONGINT$TSTREAM
(dbf_memo.pas:278)
==13664== by 0x81C6763:
DBF_DBFFILE_TDBFFILE_$__RESTRUCTURETABLE$TDBFFIELDDEFS$BOOLEAN
(dbf_dbffile.pas:1303)
==13664== by 0x81AD8B4: DBF_TDBF_$__PACKTABLE (dbf.pas:1521)
But if I use my own version (which I use for delphi and is i386 specific), it
reports no errors in this location, for Dbf_Common/Dbf_Memo.
i386 IndexByte seems way more complex than my custom MemScan, but maybe that's
necessary somehow.
Micha
_______________________________________________
fpc-devel maillist - [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel