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

Memcopy

From FenixWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 03:12, 29 April 2007 (edit)
Sandman (Talk | contribs)

← Previous diff
Current revision (12:47, 29 April 2008) (edit) (undo)
Sandman (Talk | contribs)
m
 
(One intermediate revision not shown.)
Line 3: Line 3:
==Definition== ==Definition==
-'''INT''' memcopy ( <'''VOID POINTER''' destination> , <'''VOID POINTER''' origin> , '''INT''' size )+'''INT''' memcopy ( <'''VOID POINTER''' destination> , <'''VOID POINTER''' origin> , <'''INT''' size> )
Copies a certain number of [[byte]]s from one point in [[memory]] to another. Copies a certain number of [[byte]]s from one point in [[memory]] to another.
Line 55: Line 55:
End End
</pre> </pre>
-Used in example: [[alloc]](), [[memset]](), [[say]](), [[free]](), [[array]], [[pointer]]+Used in example: [[alloc]](), [[memset]](), [[memcopy]](), [[say]](), [[free]](), [[array]], [[pointer]]
 + 
 +{{Funcbox
 + | category = Memory
 +}}

Current revision


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