Fenix Manual
Fenix Manual
Command Reference
Memory Commands

Alloc
Free
Map_Buffer
Memcopy
Memory_Total
Memory_Free
Memset
Memsetw
Realloc

Alloc
Last Modified: May 29, 2005 21:05PM
(Any)
Description

POINTER ALLOC(INT BYTES)

PARAMETERS:
bytes: Size in bytes of the memory zone to reserve.

DESCRIPTION:
It reserves a memory zone, and gives back a pointer to the same one. This is a function outpost, that requires knowledge of the concept of pointers. This memory zone can contain random rest of a previous use, or data. It is the responsibility of the programmer to initialise it.

The pointer given back by Alloc can be assigned to any variable of pointer type (like a byte to pointer or int to pointer).

It is advised to keep the pointer as a global variable, and to access the reserved memory using the operator [ ] throughout the program.

If there is not sufficient memory available, Alloc will generate an error in run time. Nevertheless it is a rare problem, since the operating system can use the free space in hard disk to emulate the existence of memory (virtual memory).

The number of elements that will fit into the new memory zone will be equivalent to the number of bytes, divided by the size of each element. If we want to reserve memory to keep 1000 data from type "byte", we must reserve 1000 bytes, whereas if we wished to keep 1000 data from type int, it will be precise to reserve to 4000 bytes (since Sizeof(int) is 4, 4*1000 = 4000).

The given back pointer does not have to discarded, since it is precise to use it, there is more overhead when calling the function Free, to release memory.

User Contributed Notes
Alloc
Add Notes About Notes
There are no user contributed notes for this page.
Last updated: Mon, 30 May 2005 - 10:33:03

Manual © 2005 By Gary Moncrieff(Dazzy), Notes belong to their respective posters