The Tiny HTM Library
Functions
Variable length integer encoding/decoding

Functions

HTM_INLINE unsigned int htm_varint_len (uint64_t val)
 Returns the number of bytes required to represent val.
HTM_INLINE unsigned int htm_varint_nfollow (unsigned char leadbyte)
 Returns the number of bytes following the specified leading byte (in a variable length coding of an unsigned integer).
HTM_INLINE uint64_t htm_varint_decode (const unsigned char *buf)
 Decodes the variable length integer encoded at buf.
HTM_INLINE unsigned int htm_varint_encode (unsigned char *buf, const uint64_t val)
 Variable-length encodes val into the given buffer, which must point to a buffer of at least 8 bytes.
HTM_INLINE unsigned int htm_varint_rencode (unsigned char *buf, const uint64_t val)
 Variable-length encodes val into the given buffer, which must point to a buffer of at least 8 bytes.

Function Documentation

HTM_INLINE unsigned int htm_varint_encode ( unsigned char *  buf,
const uint64_t  val 
)

Variable-length encodes val into the given buffer, which must point to a buffer of at least 8 bytes.

The number of bytes actually used in the encoding is returned.

Definition at line 72 of file varint.h.

References htm_varint_len(), and htm_s2cpoly::n.

HTM_INLINE unsigned int htm_varint_rencode ( unsigned char *  buf,
const uint64_t  val 
)

Variable-length encodes val into the given buffer, which must point to a buffer of at least 8 bytes.

Bytes are written in the reverse order of htm_varint_encode(). The number of bytes actually used in the encoding is returned.

Definition at line 95 of file varint.h.

References htm_varint_len(), and htm_s2cpoly::n.