Show More
@@ -264,11 +264,12 b' static const char *index_node_existing(i' | |||
|
264 | 264 | |
|
265 | 265 | static int nt_insert(indexObject *self, const char *node, int rev); |
|
266 | 266 | |
|
267 |
static int node_check(PyObject *obj, char **node |
|
|
267 | static int node_check(PyObject *obj, char **node) | |
|
268 | 268 | { |
|
269 | if (PyBytes_AsStringAndSize(obj, node, nodelen) == -1) | |
|
269 | Py_ssize_t nodelen; | |
|
270 | if (PyBytes_AsStringAndSize(obj, node, &nodelen) == -1) | |
|
270 | 271 | return -1; |
|
271 |
if ( |
|
|
272 | if (nodelen == 20) | |
|
272 | 273 | return 0; |
|
273 | 274 | PyErr_SetString(PyExc_ValueError, "20-byte hash required"); |
|
274 | 275 | return -1; |
@@ -279,7 +280,7 b' static PyObject *index_insert(indexObjec' | |||
|
279 | 280 | PyObject *obj; |
|
280 | 281 | char *node; |
|
281 | 282 | int index; |
|
282 |
Py_ssize_t len |
|
|
283 | Py_ssize_t len; | |
|
283 | 284 | |
|
284 | 285 | if (!PyArg_ParseTuple(args, "iO", &index, &obj)) |
|
285 | 286 | return NULL; |
@@ -289,7 +290,7 b' static PyObject *index_insert(indexObjec' | |||
|
289 | 290 | return NULL; |
|
290 | 291 | } |
|
291 | 292 | |
|
292 |
if (node_check(PyTuple_GET_ITEM(obj, 7), &node |
|
|
293 | if (node_check(PyTuple_GET_ITEM(obj, 7), &node) == -1) | |
|
293 | 294 | return NULL; |
|
294 | 295 | |
|
295 | 296 | len = index_length(self); |
@@ -1214,15 +1215,14 b' cleanup:' | |||
|
1214 | 1215 | static PyObject *index_getitem(indexObject *self, PyObject *value) |
|
1215 | 1216 | { |
|
1216 | 1217 | char *node; |
|
1217 | Py_ssize_t nodelen; | |
|
1218 | 1218 | int rev; |
|
1219 | 1219 | |
|
1220 | 1220 | if (PyInt_Check(value)) |
|
1221 | 1221 | return index_get(self, PyInt_AS_LONG(value)); |
|
1222 | 1222 | |
|
1223 |
if (node_check(value, &node |
|
|
1223 | if (node_check(value, &node) == -1) | |
|
1224 | 1224 | return NULL; |
|
1225 |
rev = index_find_node(self, node, |
|
|
1225 | rev = index_find_node(self, node, 20); | |
|
1226 | 1226 | if (rev >= -1) |
|
1227 | 1227 | return PyInt_FromLong(rev); |
|
1228 | 1228 | if (rev == -2) |
@@ -1360,14 +1360,13 b' static PyObject *index_partialmatch(inde' | |||
|
1360 | 1360 | |
|
1361 | 1361 | static PyObject *index_shortest(indexObject *self, PyObject *args) |
|
1362 | 1362 | { |
|
1363 | Py_ssize_t nodelen; | |
|
1364 | 1363 | PyObject *val; |
|
1365 | 1364 | char *node; |
|
1366 | 1365 | int length; |
|
1367 | 1366 | |
|
1368 | 1367 | if (!PyArg_ParseTuple(args, "O", &val)) |
|
1369 | 1368 | return NULL; |
|
1370 |
if (node_check(val, &node |
|
|
1369 | if (node_check(val, &node) == -1) | |
|
1371 | 1370 | return NULL; |
|
1372 | 1371 | |
|
1373 | 1372 | self->ntlookups++; |
@@ -1383,16 +1382,15 b' static PyObject *index_shortest(indexObj' | |||
|
1383 | 1382 | |
|
1384 | 1383 | static PyObject *index_m_get(indexObject *self, PyObject *args) |
|
1385 | 1384 | { |
|
1386 | Py_ssize_t nodelen; | |
|
1387 | 1385 | PyObject *val; |
|
1388 | 1386 | char *node; |
|
1389 | 1387 | int rev; |
|
1390 | 1388 | |
|
1391 | 1389 | if (!PyArg_ParseTuple(args, "O", &val)) |
|
1392 | 1390 | return NULL; |
|
1393 |
if (node_check(val, &node |
|
|
1391 | if (node_check(val, &node) == -1) | |
|
1394 | 1392 | return NULL; |
|
1395 |
rev = index_find_node(self, node, |
|
|
1393 | rev = index_find_node(self, node, 20); | |
|
1396 | 1394 | if (rev == -3) |
|
1397 | 1395 | return NULL; |
|
1398 | 1396 | if (rev == -2) |
@@ -1403,17 +1401,16 b' static PyObject *index_m_get(indexObject' | |||
|
1403 | 1401 | static int index_contains(indexObject *self, PyObject *value) |
|
1404 | 1402 | { |
|
1405 | 1403 | char *node; |
|
1406 | Py_ssize_t nodelen; | |
|
1407 | 1404 | |
|
1408 | 1405 | if (PyInt_Check(value)) { |
|
1409 | 1406 | long rev = PyInt_AS_LONG(value); |
|
1410 | 1407 | return rev >= -1 && rev < index_length(self); |
|
1411 | 1408 | } |
|
1412 | 1409 | |
|
1413 |
if (node_check(value, &node |
|
|
1410 | if (node_check(value, &node) == -1) | |
|
1414 | 1411 | return -1; |
|
1415 | 1412 | |
|
1416 |
switch (index_find_node(self, node, |
|
|
1413 | switch (index_find_node(self, node, 20)) { | |
|
1417 | 1414 | case -3: |
|
1418 | 1415 | return -1; |
|
1419 | 1416 | case -2: |
@@ -1897,13 +1894,12 b' static int index_assign_subscript(indexO' | |||
|
1897 | 1894 | PyObject *value) |
|
1898 | 1895 | { |
|
1899 | 1896 | char *node; |
|
1900 | Py_ssize_t nodelen; | |
|
1901 | 1897 | long rev; |
|
1902 | 1898 | |
|
1903 | 1899 | if (PySlice_Check(item) && value == NULL) |
|
1904 | 1900 | return index_slice_del(self, item); |
|
1905 | 1901 | |
|
1906 |
if (node_check(item, &node |
|
|
1902 | if (node_check(item, &node) == -1) | |
|
1907 | 1903 | return -1; |
|
1908 | 1904 | |
|
1909 | 1905 | if (value == NULL) |
General Comments 0
You need to be logged in to leave comments.
Login now