4.2.4 Reusing Deleted Records

Any RMS definition file created or modified with filedef(C-1) has an option set that forces the reuse of deleted records. For sequential or indexed sequential file access methods, the first record of the RMS data file is a pointer to the next deleted record. This pointer record is not accessible to normal RMS routines. Only dinsert(C-3) and ddelete(C-3) modify this pointer record. As records are deleted, they are linked into the head of the list. The deleted record itself becomes a pointer to additional deleted records. As records are inserted, if there are previously deleted records available in the deleted record chain, they are removed from the chain and used instead of appending a new record at the end of the RMS data file. Be warned that deleting a record and then reinserting the same record does not necessarily put the record back in the same place.

For hashed files, the first record is still treated as special. Again, normal RMS routines ignore this record. When deleting a record, no special action is taken. When a new record is being inserted, the first deleted record is used if it is found before an unused record. As with sequential files, deleting a record and reinserting it does not always put the record back in the same place.