%ALLOC (Allocate Storage)

%ALLOC(num)

%ALLOC returns a pointer to newly allocated heap storage of the length specified. The newly allocated storage is uninitialized.

The parameter must be a non-float numeric value with zero decimal places. The length specified must be between 1 and the maximum size allowed.

The maximum size allowed depends on the type of heap storage used for RPG memory management operations due to the ALLOC keyword on the Control specification. If the module uses teraspace heap storage, the maximum size allowed is 4294967295 bytes. Otherwise, the maximum size allowed is 16776704 bytes.

The maximum size available at runtime may be less than the maximum size allowed by RPG.

For more information, see Memory Management Operations.

If the operation cannot complete successfully, exception 00425 or 00426 is issued.

Figure 193. %ALLOC Example
 *..1....+....2....+....3....+....4....+....5....+....6....+....7...+....
 /FREE
   // Allocate an area of 200 bytes
   pointer = %ALLOC(200);
 /END-FREE


[ Top of Page | Previous Page | Next Page | Contents | Index ]