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
- -1 if the string doesn't fit; in this case, the pointer referred to by Sp will have been advanced by the amount of the number that fitted;
- Zero is returned if the number was written successfully.
See Also:
Notes
This function and the companion LQT_sReadNumber 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_sWriteNumber 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.