Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
486 B

  1. #include "fmt.h"
  2. /* write int in least amount of bytes, return number of bytes */
  3. /* as used in varints from Google protocol buffers */
  4. size_t fmt_varint(char* dest,unsigned long long l) {
  5. /* high bit says if more bytes are coming, lower 7 bits are payload; little endian */
  6. size_t i;
  7. for (i=0; l; ++i, l>>=7) {
  8. if (dest) dest[i]=(l&0x7f) | ((!!(l&~0x7f))<<7);
  9. }
  10. return i;
  11. }
  12. size_t fmt_pb_type0_int(char* dest,unsigned long long l) __attribute__((alias("fmt_varint")));