Kbase P109354: Invoking the SET-SIZE function does not cause a MEMPTR to be reallocated to the new size
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  27/01/2006 |
|
Status: Verified
FACT(s) (Environment):
OpenEdge 10.x
Progress 9.x
SYMPTOM(s):
Invoking the SET-SIZE function does not cause a MEMPTR to be reallocated to the new size
The SET-SIZE function is invoked multiple times for the MEMPTR variable
CAUSE:
Invoking the SET-SIZE function against a MEMPTR variable a second time will not cause the MEMPTR to be reallocated to the new size. For example, the following code will not change the size of the MEMPTR to 25,000 bytes. After the second invocation of SET-SIZE the size of the MEMPTR will still be 1,000 bytes:
DEFINE VARIABLE vPointer AS MEMPTR NO-UNDO.
SET-SIZE(vPointer) = 1000.
MESSAGE GET-SIZE(vPointer) VIEW-AS ALERT-BOX.
SET-SIZE(vPointer) = 25000.
MESSAGE GET-SIZE(vPointer) VIEW-AS ALERT-BOX.
FIX:
In order to reallocate the MEMPTR variable to a new size the memory that the MEMPTR points to must be deallocated first. This is done by using the SET-SIZE function to set the new size to zero. For example, the follow code (from above) shows how to correctly reallocate a MEMPTR to a different size:
DEFINE VARIABLE vPointer AS MEMPTR NO-UNDO.
SET-SIZE(vPointer) = 1000.
MESSAGE GET-SIZE(vPointer) VIEW-AS ALERT-BOX.
SET-SIZE(vPointer) = 0.
SET-SIZE(vPointer) = 25000.
MESSAGE GET-SIZE(vPointer) VIEW-AS ALERT-BOX.