FreeBSD/contrib/binutils/binutils/readelf.c
/* Read an unsigned LEB128 encoded value from p.  Set *PLEN to the number of
   bytes read.  */
Read an unsigned LEB128 encoded value from p.  Set *PLEN to the number of
bytes read.
Read an unsigned LEB128 encoded value from p . Set * PLEN to the number of bytes read .
static unsigned int
read_uleb128 (unsigned char *p, unsigned int *plen)
{
  unsigned char c;
  unsigned int val;
  int shift;
  int len;
  val = 0;
  shift = 0;
  len = 0;
  do
    {
      c = *(p++);
      len++;
      val |= ((unsigned int)c & 0x7f) << shift;
      shift += 7;
    }
  while (c & 0x80);
  *plen = len;
  return val;
}
static unsigned int read_uleb128 ( unsigned char * p , unsigned int * plen ) { unsigned char c ; unsigned int val ; int shift ; int len ; val = 0 ; shift = 0 ; len = 0 ; do { c = * ( p ++ ) ; len ++ ; val |= ( ( unsigned int ) c & 0x7f ) << shift ; shift += 7 ; } while ( c & 0x80 ) ; * plen = len ; return val ; }
Read an unsigned LEB128 encoded value from p.  Set *PLEN to the number of
bytes read.
Read an unsigned LEB128 encoded value from p . Set * PLEN to the number of bytes read .