Core Function Alloc

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "<pre> Alloc( <size>, <flag> ) </pre> === Description === Allocate memory and return the pointer to it. === Parameters=== ==== size ==== Size in bytes to allocate. ==== flag...")
 
Line 25: Line 25:
 
=== Remarks ===
 
=== Remarks ===
  
None.
+
Using alloc etc its even possible to create your own memory based functions such as your own DLLStruct functions.
  
 
=== Example ===
 
=== Example ===

Revision as of 15:44, 10 December 2011

Alloc( <size>, <flag> )

Contents

Description

Allocate memory and return the pointer to it.

Parameters

size

Size in bytes to allocate.

flag

Optional; If higher than 0 the allocated memory will be zeroed.

Return Value

Success: Returns a valid pointer.

Failure: Returns 0.

Remarks

Using alloc etc its even possible to create your own memory based functions such as your own DLLStruct functions.

Example

$PTR = Alloc(300);
 
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);
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox