M$SIZE
The M$SIZE library routine retrieves the size of a memory region.
The memory region is usually allocated with the M$ALLOC library routine. However, programs compiled with -cp option may operate also on a memory regions allocated by external C functions or by a Format 7 SET statement.
Syntax:
 CALL "M$SIZE" USING memAddress
              GIVING memSize
Parameters:
memAddress
USAGE HANDLE
Specifies the handle to the memory region.
 
Note - for compatibility reasons this item may also be defined as USAGE POINTER. In this case the program must be compiled either with -ca or -cp options. With -ca POINTER is translated to HANDLE. With -cp POINTER is a real pointer that can be shared with external C routines.
Return code:
memSize can be any numeric data item. It receives the size of the memory region pointed by memAddress.
Examples:
Example - Allocate 8 bytes of memory, check if the memory size is 8
*> define msize as pic 9(2) and mem1 usage handle
 
call "m$alloc" using 8, mem1
call "m$size" using mem1 giving msize
if msize not = 8
   display "Error allocating memory"
end-if