Progress
Language Reference
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, and deallocating memory associated with an MEMPTR variable.
SYNTAX
memptr-var
A reference to a variable defined as MEMPTR.
size
An integer expression that specifies the size of the region pointed to by memptr-var.
EXAMPLEThis example, the SET-SIZE statement allocates 8 bytes of memory and associates it with ElipRegion. It then initializes the region with four SHORT (2-byte) values.
NOTES
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 memptr-var has no memory allocated to it (is uninitialized), then the SET-SIZE statement allocates a memory region of the specified size.
- If memptr-var is returned from a DLL or UNIX shared library routine that also allocates a memory region to it, then the SETSIZE statement initializes the size of the existing region. Progress does not allocate a new region. This allows Progress to perform bounds checking on references to MEMPTR regions allocated outside Progress.
- 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 leaves memptr-var unchanged.
- After initializing memptr-var, you can obtain the address of (or pointer to) the region associated with memptr-var 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 Progress, see the Progress External Program Interfaces manual.
SEE ALSO
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |