equal
deleted
inserted
replaced
8 */ |
8 */ |
9 |
9 |
10 #include <Python.h> |
10 #include <Python.h> |
11 #include <assert.h> |
11 #include <assert.h> |
12 #include <ctype.h> |
12 #include <ctype.h> |
|
13 #include <limits.h> |
13 #include <stddef.h> |
14 #include <stddef.h> |
14 #include <string.h> |
15 #include <string.h> |
15 |
16 |
16 #include "bitmanipulation.h" |
17 #include "bitmanipulation.h" |
17 #include "charencode.h" |
18 #include "charencode.h" |
215 uint32_t offset_high = getbe32(data); |
216 uint32_t offset_high = getbe32(data); |
216 offset |= ((uint64_t)offset_high) << 32; |
217 offset |= ((uint64_t)offset_high) << 32; |
217 } |
218 } |
218 } |
219 } |
219 return (int64_t)(offset >> 16); |
220 return (int64_t)(offset >> 16); |
|
221 } |
|
222 |
|
223 static inline int index_get_length(indexObject *self, Py_ssize_t rev) |
|
224 { |
|
225 if (rev >= self->length) { |
|
226 PyObject *tuple; |
|
227 PyObject *pylong; |
|
228 long ret; |
|
229 tuple = PyList_GET_ITEM(self->added, rev - self->length); |
|
230 pylong = PyTuple_GET_ITEM(tuple, 1); |
|
231 ret = PyInt_AsLong(pylong); |
|
232 if (ret == -1 && PyErr_Occurred()) { |
|
233 return -1; |
|
234 } |
|
235 if (ret < 0 || ret > (long)INT_MAX) { |
|
236 PyErr_Format(PyExc_OverflowError, |
|
237 "revlog entry size out of bound (%ld)", |
|
238 ret); |
|
239 return -1; |
|
240 } |
|
241 return (int)ret; |
|
242 } else { |
|
243 const char *data = index_deref(self, rev); |
|
244 return (int)getbe32(data + 8); |
|
245 } |
220 } |
246 } |
221 |
247 |
222 /* |
248 /* |
223 * RevlogNG format (all in big endian, data may be inlined): |
249 * RevlogNG format (all in big endian, data may be inlined): |
224 * 6 bytes: offset |
250 * 6 bytes: offset |