2 * This software is part of the SBCL system. See the README file for
5 * This software is derived from the CMU CL system, which was
6 * written at Carnegie Mellon University and released into the
7 * public domain. The software is in the public domain and is
8 * provided with absolutely no warranty. See the COPYING and CREDITS
9 * files for more information.
12 // Read a variable-length encoded 32-bit integer from SOURCE and
15 // If OFFSET is not NULL, start decoding at OFFSET bytes from SOURCE
16 // and increment the value pointed to by OFFSET by the length of the
17 // encoded representation.
19 // Keep in sync with {READ,WRITE}-VAR-INTEGER in
20 // src/code/debug-var-io.lisp
21 int read_var_integer(unsigned char *source
, int *offset
) {
22 unsigned char *ptr
= source
+ (offset
? *offset
: 0);
26 for (;; k
+= 7, ++ptr
){
28 result
|= (octet
& 0x7f) << k
;
29 if (!(octet
& 0x80)) {
34 *offset
+= (ptr
- source
);