This wiki is out of date, use the continuation of this wiki instead

Memcopy

From FenixWiki

Jump to: navigation, search


Contents

[edit] Definition

INT memcopy ( <VOID POINTER destination> , <VOID POINTER origin> , <INT size> )

Copies a certain number of bytes from one point in memory to another.

[edit] Parameters

VOID POINTER destination - Pointer to the first byte of the destination.
VOID POINTER origin - Pointer to the first byte of the origin.
INT size - The size of the to be copied memory in bytes.

[edit] Returns

INT : true

[edit] Example

Program example;
Const
    elements = 10;
End
Private
    byte bytearray[elements*2];
    byte pointer pbyte;
    int i;
End
Begin

    // Allocate memory
    pbyte = alloc(elements);

    // Write numbers to bytes
    memset(pbyte,133,elements);

    // Copy bytes to bytearray
    memcopy(&bytearray[0],pbyte,elements);

    // Show numbers
    for(i=0; i<elements; i++)
        say("byte["+i+"] = " + bytearray[i]);
    end

    Repeat
        frame;
    Until(key(_esc))

    // Free the used memory
    free(pbyte);

End

Used in example: alloc(), memset(), memcopy(), say(), free(), array, pointer


Memory Functions
Alloc() • Free() • Memcmp() • Memcopy() • Memory_free() • Memory_total() • Memset() • Memsetw() • Realloc() •
Personal tools