Thema: Delphi StrLCopy : Non VCL

Einzelnen Beitrag anzeigen

hathor
(Gast)

n/a Beiträge
 
#15

AW: StrLCopy : Non VCL

  Alt 28. Apr 2012, 13:01
Übrigens: lstrcpyn function - MSDN schreibt:
Copies a specified number of characters from a source string into a buffer.
Warning Do not use.
Consider using StringCchCopy instead.

Bevor ich das mit LAZARUS testen kann (ist auf einem anderen Notebook) zeige ich mal den Code von der Borland Software Corporation:

Delphi-Quellcode:
function StrLCopy(Dest: PChar; const Source: PChar; MaxLen: Cardinal): PChar; assembler;
asm
        PUSH EDI
        PUSH ESI
        PUSH EBX
        MOV ESI,EAX
        MOV EDI,EDX
        MOV EBX,ECX
        XOR AL,AL
        TEST ECX,ECX
        JZ @@1
        REPNE SCASB
        JNE @@1
        INC ECX
@@1: SUB EBX,ECX
        MOV EDI,ESI
        MOV ESI,EDX
        MOV EDX,EDI
        MOV ECX,EBX
        SHR ECX,2
        REP MOVSD
        MOV ECX,EBX
        AND ECX,3
        REP MOVSB
        STOSB
        MOV EAX,EDX
        POP EBX
        POP ESI
        POP EDI
end;
---------------
FPC currently uses 32 bits (4 bytes) for integers, whether the machine is a 32-bit or 64-bit machine. This will cause code expecting an integer and a pointer to be the same size to fail as a 64-bit machine uses 64-bit pointers. To allow you to write portable code, the FPC system unit introduces the types PtrInt and PtrUInt which are signed and unsigned integer data types with the same size as a pointer.
http://wiki.freepascal.org/Integer
Miniaturansicht angehängter Grafiken
fpc_integer-types.jpg  

Geändert von hathor (28. Apr 2012 um 13:21 Uhr)
  Mit Zitat antworten Zitat