#include "my_global.h"Include dependency graph for my_vle.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Defines | |
| #define | my_vle_sizeof(ITEM) (((sizeof(ITEM) * CHAR_BIT) + 6) / 7) |
Functions | |
| byte * | my_vle_encode (byte *vle, my_size_t max, ulong value) |
| byte const * | my_vle_decode (ulong *value_ptr, byte const *vle) |
| #define my_vle_sizeof | ( | ITEM | ) | (((sizeof(ITEM) * CHAR_BIT) + 6) / 7) |
Definition at line 97 of file my_vle.c.
00098 { 00099 ulong result= 0; 00100 my_size_t cnt= 1; 00101 00102 do 00103 { 00104 result<<= 7; 00105 result|= (*vle & 0x7F); 00106 } 00107 while ((*vle++ & 0x80) && ++cnt <= sizeof(*result_ptr) + 1); 00108 00109 if (cnt <= sizeof(*result_ptr) + 1) 00110 *result_ptr= result; 00111 00112 return vle; 00113 }
Definition at line 47 of file my_vle.c.
References buf, and my_vle_sizeof.
00048 { 00049 byte buf[my_vle_sizeof(n)]; 00050 byte *ptr= buf; 00051 my_size_t len; 00052 00053 do 00054 { 00055 *ptr++= (n & 0x7F); 00056 n>>= 7; 00057 } 00058 while (n > 0); 00059 00060 len= ptr - buf; 00061 00062 if (len <= max) 00063 { 00064 /* 00065 The bytes are stored in reverse order in 'buf'. Let's write them 00066 in correct order to the output buffer and set the MSB at the 00067 same time. 00068 */ 00069 while (ptr-- > buf) 00070 { 00071 byte v= *ptr; 00072 if (ptr > buf) 00073 v|= 0x80; 00074 *out++= v; 00075 } 00076 } 00077 00078 return out; 00079 }
1.4.7

