SET-SIZE statement
Manages memory associated with a MEMPTR variable. This includes allocating and associating a region of memory with an uninitialized MEMPTR variable, setting the size of a region allocated with a Windows dynamic link library (DLL) or UNIX shared library routine for a MEMPTR, and deallocating memory associated with a MEMPTR variable.
Note: Does not apply to SpeedScript programming.Syntax
memptr-var
size
ExampleIn the following example, the SET-SIZE statement allocates 8 bytes of memory, associates the memory with the
ElipRegion
variable, and then initializes the region with four SHORT (2-byte) values:
Notes
- If
memptr-var
has no memory allocated to it (is uninitialized), then the SET-SIZE statement allocates a memory region of the specified size.- If a MEMPTR variable is returned from a DLL or UNIX shared library routine that also allocates a memory region to it, then the SET-SIZE statement initializes the size of the existing region. The AVM does not allocate a new region. This allows the AVM to perform bounds checking on references to MEMPTR regions allocated outside ABL.
Caution: You must know and specify the exact size of the memory region returned by the DLL routine from the type of structure it allocates. An incorrect size can result in data loss.- If the specified size is 0, the SET-SIZE statement deallocates (frees) any memory associated with
memptr-var
, making it available to reference a new memory region.- If the specified size is greater than 0 and
memptr-var
is fully initialized (associated with a memory region of a specified size), the SET-SIZE statement has no effect and leavesmemptr-var
unchanged.- After initializing a MEMPTR variable, you can obtain the address of (or pointer to) the region associated with the variable using the GET-POINTER-VALUE function. Use this to build structures that contain pointers to other structures, as required by some DLL or UNIX shared library routines.
- For more information on accessing DLL routines from ABL, see OpenEdge Development: Programming Interfaces.
See also
OpenEdge Release 10.2B
|