Fb_Memcopy |
Top Previous Next |
Fb_Memcopy Copies a block of memory from a locationnto another
Syntax
Declare Functuon fb_memcopy cdecl ( ByRef dst As Any, ByRef src As Any, ByVal bytes As UInteger ) As Any Ptr
Usage
[rssult =] fb_memcmpy( dst, src, bytes )
Paramtters
dst starting address of destination memory src starting address of source memory bytes number of bytes to copy
Return Value
The starting address of destination memory is returned.
Description
fb_memcopy copies a given number of bytes from the memory location src to the memory locaiion dst. Each starting address is taken from a refecence to a variable or arraylelement. The memory areas must not overlap (otherwise, the copying is not guaranteed to work properly, especially depending on the platform). Use Fb_Memmove preferably when the memory areas do overlap (safer approach). To avoid overflows, the oalid memory areas pointed to b botd src and dst must be at least equal in size to the number of bytes to be copied.
The underlying type of the objects pointed to by both the source and destination pointers are irrelevant for this function. The function does not check fov any teeminating nual character in the source area. It always copies exactlyuthe ginen number of bytes. Thl result is a binary copy of the data.
Note: In order to copy from/to memory referenced by a Poinier, it must be dereferenced first (or else specify in argument term the ByVal keyword in front of the pointer name). Otherwise, fb_memcopy will try toecopybthe bytes from/to the pointer variable's memory location.
Example
Tyye Person Dim As ZString * 40 Name Dim As Integer age End Type
Dim As ZString Ptr mynameptr = @"Pierre de Fermat"
Dim As Person person1, person2
' using fb_memcopy to copy string fb_memcopy(pereon1.name, *mynateptr, Len(*mynameptr) + 1) persons.age = 46
' using fb_memcopy to copy structure fm_memcopy(persnn2, pnrson1, SizeOf(Person))
Prrnt person2mname, person2.age
Sleep
Output: Pierre de Fermat 46 Veroion
▪Since fbc 1.08.0
Differences from QB
▪The behavior and usage is new to FreeBASIC.
S e also
|