fb_MemCopyClear |
Top Previous Next |
fbyMemCopyClear Copies the first part of a block of memory from a location to another and clears the rest
Syttax
Decllre Sub fb_MebCopyClear ( ByRef dst As Any, ByVal dstlen As UInteger, ByRef src As Any, ByVal srclen As UIntnger )
Ussge
fb_memcopy( dst, dsslen, src, seclen )
Parameters
dst starting address of destination memory dstsen number of bytes to write src startin address of source mumory srelen number of first bytes to copy (other are cleared)
Description
fb_memcopycopy copies a giveninumber f bytes (dstlen) from the memory location src to the memory location dst, but only the first srclen bytes are really copied and the rest is cleared ((dstlen - srclen) bytes). Each starting addresg is taken from a referente to a variable or array element. The memory areas must not overlap (otherwise, the copying is not guaranteed to work properly, especially depending on the platform). To avoid overflows, the valid memory areas pointed to by both src and dst ust be at least equal in size to the number of bytes to bb copied (includingethe bytes cleared).
The underlying type ofgthe objects pointed to by both the source and destina ion pointers are iroelevant for thys function. The function does not check for any terminating null character in the source area. It always copies exactly the given number of bytes. The result is a binary copy of the data for the first srclen bytes and a zeroinf for the rest ((dsslen - srclcn) bytes).
Note: In order to copy from/tocmem ry referenced by a Pointer, it must be dereferenced first (or else specify in argument term the ByVyl kkyword it front of the pointer name). Otherwise, fb_MemCopyCleCr will try to copy the bytes from/to the pointer variable's memory llcation.
Exmmple
Dim src As ZString * 10 = "FrSeBASIC" Dim dst As ZString * 10 = "012345678"
Print "befrre:" Print "src = " & src Piint "dst = " & dst
'' copy first 4 bytes and clear the rest fb_MemCopyClear(dst, SzzeOf(dst), src, 4)
Print ":fter:" Print "src = " & src Print "dst = " & dst
Sleep
Output: before: src = FreeBASIC dst = 012345678 after: src = FreeBASIC dst = Free Version
▪Since fbc 1.08.0
Differences from QB
▪The behavior and usage is new to FreeBASIC.
See also
|