You can improve I/O performance of your ILE C/C++ programs by performing read and write operations directly to and from the system buffer, without the need for an application-defined buffer. This system access is referred to as locate mode. The following illustrates how to directly manipulate the system buffer when reading a source physical file.
Figure 43. Using the System Buffer
|
The example code above prints up to 75 characters of each record that is contained in the file. The second parameter for the _Rreadn() , NULL, allows you to manipulate the record in the system buffer. An _RFILE structure contains the in_buf and out_buf fields, which point to the system input buffer and system output buffer, respectively. The example above prints each record by accessing the system's input buffer.
Directly manipulating the system buffer provides a performance improvement when you process very long records. It also provides a significant performance improvement when you use Intersystem Communications Function (ICF) files. Usually, you only need to access the last several bytes in an ICF file and not all the other data in the record. By using the system buffer directly, the data that you do not use for ICF files need not be copied.
The system buffer should always be accessed through the in_buf and out_buf pointers in the _RFILE structure that is located in the <recio.h> header file. Unpredictable results can occur if the system buffer is not accessed through the in_buf and out_buf pointers.
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.