Core Function Alloc
From Sputnik Wiki
Alloc( <size>, <filler> )
Contents |
Description
Allocate memory and return the pointer to it.
Parameters
size
Size in bytes to allocate.
filler
Optional; If filler is given it will be used to preset all the bytes allocated to this number.
Usually used to zero all the data during allocation.
Return Value
Success: Returns a valid pointer.
Failure: Returns @PTRZero.
Remarks
Using alloc etc its even possible to create your own memory based functions such as your own DLLStruct functions.
Example
$PTR = Alloc(300); //$PTR = Alloc(300, 0x00); // All allocated data will be zeroed 0x00 PTRWrite($PTR, "f", 0, 133.77); PTRWrite($PTR, "l", 4, 777); PTRWrite($PTR, "i", 12, 1221); Println( PTRRead($PTR, "f", 0) ); Println( PTRRead($PTR, "l", 4) ); Println( PTRRead($PTR, "i", 12) ); Free($PTR);