Change Memory Allocation (CHGMEMAXCL)
The Change Memory Allocation (CHGMEMAXCL) command changes the size of a previously created memory allocation.
This function is also available with command CHGMEMALC in library VC2XCL. Any use of this alternative command name should be library qualified in case the i operating system were to use this command name in a future release.
| Keyword | Description | Choices | Notes |
| PTR |
Pointer |
Character value |
Optional, Positional 1 |
| NAME |
Name |
Character value |
Optional, Positional 2 |
| SIZE |
Size |
Integer, 4096 |
Optional |
| INZVAL |
Initialization value |
Character value |
Optional |
Pointer (PTR)
When the NAME parameter is specified the PTR parameter is not used in identifying the memory allocation to be changed.
When the NAME parameter is not specified the PTR parameter is used in identifying the memory allocation to be changed. In this case the value of the PTR parameter must be the same as the value returned by the most recent CRTMEMAXCL or CHGMEMAXCL command that referenced this memory allocation.
Due to CL commands not allowing CL variables of TYPE(*PTR) to be passed as a parameter the CL pointer variable must be passed indirectly by declaring the pointer variable as being defined on a character variable. The following demonstrates how to do this.
Dcl Var(&Chr_Ptr) Type(*Char) Len(16)
Dcl Var(&Pointer) Type(*Ptr) Stg(*Defined) +
DefVar(&Chr_Ptr)
ChgMemAXCL Ptr(&Chr_Ptr) Size(512)
After the CHGMEMAXCL command runs the pointer variable &Pointer will address the first byte of the re-allocated memory. The value of &Pointer may or may not be the same as it was prior to running the CHGMEMAXCL command.
The defined on variable (DEFVAR) must be declared with a minimum length of 16 bytes. The CL pointer variable, declared with TYPE(*PTR), must be defined on a base 1 16-byte boundary of the DEFVAR variable.
- character-value
- Specify the name of the CL variable.
Name (NAME)
Specifies the name of the memory allocation to be changed. This name is user determined and can be set with the Create Memory Allocation (CRTMEMAXCL) comamnd.
When the NAME parameter is specified the PTR parameter is not used for identifying the memory allocation to be changed.
- character-value
- Specify the name associated with the memory allocation.
Size (SIZE)
Specifies the new size of the memory allocation.
If the SIZE specified is less than the currently allocated size then the new allocation will retain the first SIZE bytes of the current allocation. Bytes beyond SIZE will be lost.
If the SIZE specified is greater than the currently allocated size then the new allocation will retain all of the data of the current memory allocation.
- 4096
- The size of the memory allocation is to be changed to 4096 bytes.
- integer
- Specify the new size of the memory allocation.
Initialization value (INZVAL)
When the SIZE parameter value is greater than the current size of the memory allocation this parameter determines how the additional storage is to be initialized. If this parameter is not specified the additional storage is not initialized to any specific value.
- character
- Specify a one byte initial value to use for the additional memory allocation.
Examples for CHGMEMAXCL
Example 1: Changing the Size of a Memory Allocation
Dcl Var(&Chr_Ptr) Type(*Char) Len(16)
Dcl Var(&Pointer) Type(*Ptr) Stg(*Defined) +
DefVar(&Chr_Ptr)
CrtMemAXCL Ptr(&Chr_Ptr) Size(5) InzVal('1')
ChgMemAXCL Ptr(&Chr_Ptr) Size(10) InzVal('2')
This example first creates a memory allocation of 5 bytes. The five bytes are initialized to the constant '1' (x'F1'). The CHGMEMAXCL command is then used to resize the memory allocation to 10 bytes. The first five bytes continue to have the value '11111'. The second five bytes however are set to '22222'.
Example 2: Complete Example Program
Member MEMAXMP of source file VC2XCL/QCLSRC contains a sample program demonstrating the use of CRTMEMAXCL, CHGMEMAXCL, and DLTMEMAXCL.
Error messages for CHGMEMAXCL
*ESCAPE Messages
- XCL5018
- Memory allocation name &1 is not in use.
- XCL5019
- No memory allocation is currently in use for the PTR value.
- XCL9002
- Function did not complete. See previously listed messages related to possible user errors.
- XCL9003
- Function did not complete. See previously listed messages for possible cause.
- XCL9004
- Function did not complete. See previously listed messages for possible cause.
- XCL9005
- Function did not complete. Contact your service provider.
|