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

Alloc

From FenixWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 14:27, 19 April 2007 (edit)
Sandman (Talk | contribs)

← Previous diff
Revision as of 14:27, 19 April 2007 (edit) (undo)
Sandman (Talk | contribs)
m (category)
Next diff →
Line 1: Line 1:
[[Category:functions]] [[Category:functions]]
-[[Category:processinteraction]]+[[Category:memory]]
==Definition== ==Definition==

Revision as of 14:27, 19 April 2007


Contents

Definition

BYTE POINTER Alloc ( <INT size> )

Allocates a block of memory of a certain size.

Parameters

INT size - The size of the to be allocated memory.

Returns

BYTE POINTER : A pointer to the first element of the allocated memory block.

Example

Program example;
Private
    byte pointer pbyte;
    int  pointer pint;
    int elements = 10;
    int i;
Begin

    // Allocate memory
    pbyte = alloc(elements);
    pint  = alloc(elements*sizeof(int));

    // Reset memory to 0's
    memset(pbyte,0,elements);
    memset(pint ,0,elements*sizeof(int));

    // Write numbers to memory
    for(i=0; i<elements; i++)
        pbyte[i]  = 133;
        *(pint+i) = 4555;
    end

    // Show numbers
    for(i=0; i<elements; i++)
        say("byte["+i+"] = " + *(pbyte+i));
        say("int ["+i+"] = " + pint[i]);
    end

    Loop
        frame;
    End
End

Used in example: memset(), pointer, say()

Personal tools