Better checking of package locks when declaring variables.
[sbcl.git] / src / runtime / var-io.c
blobc847c3d2caca6daa80a8e34708ef08e28d40e6ec
1 /*
2 * This software is part of the SBCL system. See the README file for
3 * more information.
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
13 // return its value.
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);
23 int result = 0;
24 unsigned char octet;
25 int k = 0;
26 for (;; k += 7, ++ptr){
27 octet = *ptr;
28 result |= (octet & 0x7f) << k;
29 if (!(octet & 0x80)) {
30 break;
33 if (offset) {
34 *offset += (ptr - source);
36 return result;