lq-text: LQT_BlockIsFree

API int LQT_BlockIsFree (db, Offset) t_LQTEXT_Database *db; unsigned long Offset;

Purpose

Determine the status of the block at a given byte offset from the start of the data overflow file (data). An external file, freelist, is kept in the database directory; this file uses a single bit to represent the status of each block, either in use or free. If the freelist file is removed, subsequent attempts to write to the database will fail. Read-only access will still work unless LQTRACE_READAFTERWRITE is set, whereupon LQT_Read­Block checks the status of each block before returning it; it is an error to attempt to read an unallocated block, although this not normally checked, for performance reasons.

Returns

Non-zero if the block is available, zero if it is free

Errors

Fatal error if the freelist file could not be opened

See Also:

Notes

The first few blocks are reserved for storing information about the database; they are marked as used automatically whenever a database is created.

The freelist file can be rebuilt by the lqmkfreelist program.

The test program `free' contains examples of using the Block Status functions LQT_Block­Is­Free and LQT_Set­Block­Status. It can also be used to edit the contents of the freelist file.