lq-text: LQT_sWriteNumber

INLINE int LQT_sWriteNumber (Sp, Number, Base, Maxlen) unsigned char **Sp; unsigned long Number; unsigned char *Base; unsigned int Maxlen;

Purpose

Writes a compressed binary representation of the given Number into the given string. The pointer pointed to by Sp is advanced to point to the first unwritten byte of the buffer.

Returns

See Also:

Notes

This function and the companion LQT_s­Read­Number are central to the operation of the lq-text database package. If it were not for the use of compressed numbers, the index would be too large to be useful.

The function is designed to work best with small numbers; a number less than 127 is written out in a single byte, for example, and a number less than 16383 is written in two bytes. For this reason, LQT_s­Write­Number is most effectively used when writing a sorted sequence of numbers, as then you can write only the difference between successive values, saving space. This form of delta coding is used extensively by lq-text.