##// END OF EJS Templates
parsers: replace magic number 64 with symbolic constant
Bryan O'Sullivan -
r16863:bbedef66 default
parent child Browse files
Show More
@@ -276,6 +276,9 b' static char *tuple_format = "Kiiiiiis#";'
276 276 static char *tuple_format = "kiiiiiis#";
277 277 #endif
278 278
279 /* A RevlogNG v1 index entry is 64 bytes long. */
280 static const long v1_hdrsize = 64;
281
279 282 /*
280 283 * Return a pointer to the beginning of a RevlogNG record.
281 284 */
@@ -292,7 +295,7 b' static const char *index_deref(indexObje'
292 295 return self->offsets[pos];
293 296 }
294 297
295 return PyString_AS_STRING(self->data) + pos * 64;
298 return PyString_AS_STRING(self->data) + pos * v1_hdrsize;
296 299 }
297 300
298 301 /*
@@ -1137,17 +1140,16 b' static long inline_scan(indexObject *sel'
1137 1140 {
1138 1141 const char *data = PyString_AS_STRING(self->data);
1139 1142 const char *end = data + PyString_GET_SIZE(self->data);
1140 const long hdrsize = 64;
1141 long incr = hdrsize;
1143 long incr = v1_hdrsize;
1142 1144 Py_ssize_t len = 0;
1143 1145
1144 while (data + hdrsize <= end) {
1146 while (data + v1_hdrsize <= end) {
1145 1147 uint32_t comp_len;
1146 1148 const char *old_data;
1147 1149 /* 3rd element of header is length of compressed inline data */
1148 1150 comp_len = getbe32(data + 8);
1149 incr = hdrsize + comp_len;
1150 if (incr < hdrsize)
1151 incr = v1_hdrsize + comp_len;
1152 if (incr < v1_hdrsize)
1151 1153 break;
1152 1154 if (offsets)
1153 1155 offsets[len] = data;
@@ -1158,7 +1160,7 b' static long inline_scan(indexObject *sel'
1158 1160 break;
1159 1161 }
1160 1162
1161 if (data != end && data + hdrsize != end) {
1163 if (data != end && data + v1_hdrsize != end) {
1162 1164 if (!PyErr_Occurred())
1163 1165 PyErr_SetString(PyExc_ValueError, "corrupt index file");
1164 1166 return -1;
@@ -1201,11 +1203,11 b' static int index_init(indexObject *self,'
1201 1203 self->raw_length = len;
1202 1204 self->length = len + 1;
1203 1205 } else {
1204 if (size % 64) {
1206 if (size % v1_hdrsize) {
1205 1207 PyErr_SetString(PyExc_ValueError, "corrupt index file");
1206 1208 goto bail;
1207 1209 }
1208 self->raw_length = size / 64;
1210 self->raw_length = size / v1_hdrsize;
1209 1211 self->length = self->raw_length + 1;
1210 1212 }
1211 1213
General Comments 0
You need to be logged in to leave comments. Login now