Speeding Dynamic Loading with an Index File

Dynamic loading is accomplished using indices into the text file that are stored in the memory file line structure at the time that mf_rd() loads the text file. To save the time to create this index every time the application runs, you can specify that the index file be saved to disk. Thus, the next time the program runs, mf_rd() does not need to calculate the indices again; it will read the index file on the disk instead.

To have mf_rd() create and save the index file to disk, you set the indexing option ON for the memory file. To do this, you use the set memory file options function, smf_opt():

void smf_opt(opt, state, mfp)
 
int opt;
/* Options to set
*/
int state;
/* State to set options (ON or OFF)
*/
MFILEPTR mfp;
/* Pointer to memory file
*/

For opt, specify INDEXING. For state, specify ON or OFF. For mfp, specify a pointer to the memory file you want to save the index file for. For example, to enable the creation of the index file, call:

smf_opt(INDEXING, ON, mfp);

Note: If you are using an indexed file and have modified it, it is important to delete the file when you are finished with it, so that new indexes can be calculated.


Home Contents Previous Next