SET-SIZE statement
- Last Updated: February 11, 2026
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
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
- A reference to a variable defined as MEMPTR.
- size
- An integer expression that specifies the allocated byte size of the region pointed to by memptr-var.
Example
In 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:
r-setsiz.p
|
Notes
- If memptr-var has no memory allocated
to it (is uninitialized), then the
SET-SIZEstatement 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-SIZEstatement 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. Check the documentation for the DLL or UNIX shared library routine to determine how to deallocate the memory. If you useSET-SIZE(memptr-var) = 0to deallocate the memory, the AVM uses thesystem free()function. This may not be appropriate in all cases and may cause the AVM to crash.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-SIZEstatement 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-SIZEstatement has no effect and leaves memptr-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-VALUEfunction. 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 Programming Interfaces.