lq-text: LQT_BlockIsCached

API int LQT_BlockIsCached (db, Block) t_LQTEXT_Database *db; unsigned long Block;

Purpose

Determine whether the block at a given offset in the data file is in the block buffer cache or not. Since LQT_Read­Block returns a pointer into the cache, it is a fatal error (E_BUG) if LQT_Write­Block is called for a block that is not cached.

The cache is always large enough to hold at least the last two blocks returned by LQT_Read­Block. This is just enough to ensure that the NextOffset field in a block's header can be filled in after allocating the next block in a chain.

Returns

Non-zero if the block is cached, and zero otherwise.

Errors

Fatal error if the main data file can't be opened or created.

See Also:

Notes

As a side-effect, the CurrentBlock variable in pbcache.c is set to point to the cached block; this is used internally by the library routines in that file.