自由形式構文 | DEALLOC{(EN)} ポインター名 |
コード | 演算項目 1 | 演算項目 2 | 結果フィールド | 標識 | ||
---|---|---|---|---|---|---|
DEALLOC (E/N) | ポインター名 | _ | ER | _ |
DEALLOC 命令は、動的記憶域の割り振りの直前の 1 つを解放します。 ポインター名 は、動的記憶域割り振り命令 (RPG 内の ALLOC 命令、または他の何らかの動的記憶域割り振りメカニズム) によって直前に設定された値でなければならないポインターです。このポインターは、動的記憶域を単純に指し示すだけのものでは ありません。割り振りの始めに設定されていることも必要です。
このポインターによって指し示されている記憶域は、このプログラムによって、 あるいは活動化グループ内の他のプログラムによって、これ以降の割り振りの ために解放されます。
命令コード拡張 N が指定されている場合、ポインターは再割り振りが正常に 行われた後、*NULL に設定されます。
DEALLOC 例外 (プログラム状況コード 426) を 処理するために、命令コード拡張 'E' またはエラー標識 ER を指定できますが、 両方を指定することはできません。 エラーが発生した場合、'N' が指定されていても、 結果フィールドのポインターは変更されません。 エラー処理の詳細について は、プログラム例外/エラーを参照してください。
ポインター名 は、基底ポインター・スカラー変数 (独立フィールド、データ構造サブフィールド、テーブル名、または配列要素) でなければなりません。
このポインターがすでに *NULL であれば、実行時にエラーには なりません。
詳細については、メモリー管理命令を参照してください。
*..1....+....2....+....3....+....4....+....5....+....6....+....7...+.... D*Name++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++ * D Ptr1 S * D Fld1 S 1A D BasedFld S 7A BASED(Ptr1) /FREE // 7 bytes of storage are allocated from the heap and // Ptr1 is set to point to it Ptr1 = %alloc (7); // The DEALLOC frees the storage. This storage is now available // for allocation by this program or any other program in the // activation group. (Note that the next allocation may or // may not get the same storage back). dealloc Ptr1; // Ptr1 still points at the deallocated storage, but this pointer // should not be used with its current value. Any attempt to // access BasedFld which is based on Ptr1 is invalid. Ptr1 = %addr (Fld1); // The DEALLOC is not valid because the pointer is set to the // address of program storage. %ERROR is set to return '1', // the program status is set to 00426 (%STATUS returns 00426), // and the pointer is not changed. dealloc(e) Ptr1; // Allocate and deallocate storage again. Since operational // extender N is specified, Ptr1 has the value *NULL after the // DEALLOC. Ptr1 = %alloc (7); dealloc(n) Ptr1; /END-FREE
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.