Freeing memory associated with a MEMPTR variable
- Last Updated: January 17, 2024
- 1 minute read
- OpenEdge
- Version 12.8
- Documentation
The region of memory associated with a MEMPTR variable
remains allocated until it is freed. In some cases, the shared library
routine frees the memory; in other cases, the calling procedure
must free the memory using the SET-SIZE statement
to set its size to zero (0). ABL cannot free the memory for you.
It is up to you to ensure that the memory is freed, depending on
the functionality of each shared library routine you use.
The following code fragment shows how to pass an INPUT-OUTPUT string
value as a MEMPTR parameter in the case where ABL
allocates the memory:
|
The DLL routine is the tenth function in the anysystem.dll file.
The SET-SIZE statement allocates to mVar a
memory region large enough to hold both the input and output cString values.
The PUT-STRING statement stores the cString value
in mVar. After passing mVar to
the DLL routine, the GET-STRING statement returns
the (new) value to cString.