lq-text: LQT_FindFreeBlock

API unsigned long LQT_FindFreeBlock (db, WID, BlockLengthp, BytesWanted) t_LQTEXT_Database *db; t_WID WID; unsigned int *BlockLengthp; unsigned long BytesWanted;

Purpose

Allocates a block from the free list, and marks it as in use. The block is at least BLOCKSIZE bytes long, and may be longer, as contiguous free blocks are combined to make a single longer block as long as will fit in a single cache entry. If the BytesWanted argument is non-zero, the block will not be more than BLOCKSIZE bytes longer than than BytesWanted bytes. Since LQT_Find­Free­Block does not actually read the data from the disk (or cache), it is up to the caller to ensure that LQT_Read­Block is called, and that the resulting block's header is filled in with NumberOfBlocks equal to the value that LQT_Find­Free­Block stored in BlockLengthp.

Returns

the byte offset in the data file of the block allocated, and also the number of blocks allocated (in BlockLengthp).

See Also: