Fanuc C-Executer Operating Manual
B-62443EN-3/03E
- 818 -
------------------------------------------------------------------------------
16. Allocate new memory block <Main,Alarm,Comm>
------------------------------------------------------------------------------
[Name]
os_new_mem
[Syntax]
#include <oscall.h>
unsigned short os_new_mem( unsigned long size, unsigned int *sel ) ;
[Argument]
size Byte size of memory to allocate.
sel Segment selector which points the allocated memory
block.
[Return]
0 Successful.
0x011B No enough free memory.
0x0162 No free segment selector.
[Description]
Allocates new memory block for the application program.
Specify byte size of the memory block to allocate in "size". More
than 64KB block can be allocated. The segment selector which points
the allocated memory block is stored in "sel".
It is possible to access the top 64KB part of the allocated memory
block using a pointer in whose segment part the segment selector got
by this function is stored.
It is impossible to use the segment selector got by this function in
the other task.
[Example]
The following program gets a memory block of 100KB size.
#include <oscall.h>
#include <stdio.h>
unsigned int example( void )
{
unsigned int sel, ret ;
ret = os_new_mem( 100*1024L, &sel ) ;
if ( !ret ) {
printf( "Memory block has been allocated.\n" ) ;
return( sel ) ;
}
else {
printf( "Not enough memory.\n" ) ;
return( 0 ) ;
}
}