#include uint8_t *putvlq(uint32_t, uint8_t *); uint8_t *putvlq(uint32_t value, uint8_t *dest) { uint32_t buffer = value & 0x7f; while ((value >>= 7) > 0) { buffer <<= 8; buffer |= 0x80; buffer += value & 0x7f; } for ( ; ; ) { *dest++ = (uint8_t)buffer; if (buffer & 0x80) buffer >>= 8; else return dest; } }