Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Some useful alternatives for memory operations
Message
De
14/10/2000 15:24:17
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
Some useful alternatives for memory operations
Divers
Thread ID:
00429534
Message ID:
00429534
Vues:
57
In addition to RtlMoveMemory(), the following functions can be used to perform memory copy operations. This means that you can have several simultaneously-declared memory copy routines without having to constantly redefine the declaration of RtlMoveMemory()
DECLARE INTEGER memmove IN MSVCRT ;
   INTEGER @ lpvDest, ;
   INTEGER @ lpvSource, ;
   INTEGER dwLength

DECLARE INTEGER memcpy IN MSVCRT ;
   INTEGER @ lpvDest, ;
   INTEGER @ lpvSource, ;
   INTEGER dwLength

DECLARE INTEGER _memccpy IN MSVCRT ;
   INTEGER @ lpvDest, ;
   INTEGER @ lpvSource, ;
   SHORT c, ;
   INTEGER dwLength

&& _memccpy copies either to the Length dwLength, or until an ASCII value c
&& is encountered;  it's a useful replacement for lstrcpyn(), or for copying up
&& to a delimiter character. c must be in the range 0-255

DECLARE INTEGER strcpy IN MSVCRT ;
   STRING @ lpcDest, ;
   STRING @ lpcSource

&& Copies a null terminated string to a buffer
The first three you can play around with the data typing of lpvDest and lpvSource to perform conversions, or to copy to a static buffer - ie if you're copying from a static block of memory where a pointer is stored in a VFP numeric, and you want to copy a block of 250 characters into a VFP String:

DECLARE INTEGER memcpy IN MSVCRT STRING @, INTEGER, INTEGER
cMyBuffer = REPL(CHR(0),250)
=memcpy(@cMyBuffer, nMyStaticBlockPointer, 250)

_memccpy is extremely useful in parsing; it returns the pointer to the last address copied, so that you can continue parsing a buffer from the point where a delimiter is encountered.

I'll probably incorporate some of this into CLSHeap in the next week or so.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Répondre
Fil
Voir

Click here to load this message in the networking platform