Show More
@@ -909,6 +909,19 b' static inline void set_phase_from_parent' | |||
|
909 | 909 | phases[i] = phases[parent_2]; |
|
910 | 910 | } |
|
911 | 911 | |
|
912 | /* Take ownership of a given Python value and add it to a Python list. | |
|
913 | Return -1 on failure (including if [elem] is NULL). */ | |
|
914 | static int pylist_append_owned(PyObject *list, PyObject *elem) | |
|
915 | { | |
|
916 | int res; | |
|
917 | ||
|
918 | if (elem == NULL) | |
|
919 | return -1; | |
|
920 | res = PyList_Append(list, elem); | |
|
921 | Py_DECREF(elem); | |
|
922 | return res; | |
|
923 | } | |
|
924 | ||
|
912 | 925 | static PyObject *reachableroots2(indexObject *self, PyObject *args) |
|
913 | 926 | { |
|
914 | 927 | |
@@ -921,7 +934,6 b' static PyObject *reachableroots2(indexOb' | |||
|
921 | 934 | PyObject *roots = NULL; |
|
922 | 935 | PyObject *reachable = NULL; |
|
923 | 936 | |
|
924 | PyObject *val; | |
|
925 | 937 | Py_ssize_t len = index_length(self); |
|
926 | 938 | long revnum; |
|
927 | 939 | Py_ssize_t k; |
@@ -1002,11 +1014,8 b' static PyObject *reachableroots2(indexOb' | |||
|
1002 | 1014 | revnum = tovisit[k++]; |
|
1003 | 1015 | if (revstates[revnum + 1] & RS_ROOT) { |
|
1004 | 1016 | revstates[revnum + 1] |= RS_REACHABLE; |
|
1005 | val = PyLong_FromLong(revnum); | |
|
1006 | if (val == NULL) | |
|
1007 | goto bail; | |
|
1008 | r = PyList_Append(reachable, val); | |
|
1009 | Py_DECREF(val); | |
|
1017 | r = pylist_append_owned(reachable, | |
|
1018 | PyLong_FromLong(revnum)); | |
|
1010 | 1019 | if (r < 0) |
|
1011 | 1020 | goto bail; |
|
1012 | 1021 | if (includepath == 0) |
@@ -1047,11 +1056,8 b' static PyObject *reachableroots2(indexOb' | |||
|
1047 | 1056 | RS_REACHABLE) && |
|
1048 | 1057 | !(revstates[i + 1] & RS_REACHABLE)) { |
|
1049 | 1058 | revstates[i + 1] |= RS_REACHABLE; |
|
1050 | val = PyLong_FromSsize_t(i); | |
|
1051 | if (val == NULL) | |
|
1052 | goto bail; | |
|
1053 | r = PyList_Append(reachable, val); | |
|
1054 | Py_DECREF(val); | |
|
1059 | r = pylist_append_owned(reachable, | |
|
1060 | PyLong_FromSsize_t(i)); | |
|
1055 | 1061 | if (r < 0) |
|
1056 | 1062 | goto bail; |
|
1057 | 1063 | } |
@@ -1263,8 +1269,7 b' static PyObject *index_headrevs(indexObj' | |||
|
1263 | 1269 | if (heads == NULL) |
|
1264 | 1270 | goto bail; |
|
1265 | 1271 | if (len == 0) { |
|
1266 | PyObject *nullid = PyLong_FromLong(-1); | |
|
1267 | if (nullid == NULL || PyList_Append(heads, nullid) == -1) { | |
|
1272 | if (pylist_append_owned(heads, PyLong_FromLong(-1)) == -1) { | |
|
1268 | 1273 | Py_XDECREF(nullid); |
|
1269 | 1274 | goto bail; |
|
1270 | 1275 | } |
@@ -1308,13 +1313,9 b' static PyObject *index_headrevs(indexObj' | |||
|
1308 | 1313 | } |
|
1309 | 1314 | |
|
1310 | 1315 | for (i = 0; i < len; i++) { |
|
1311 | PyObject *head; | |
|
1312 | ||
|
1313 | 1316 | if (nothead[i]) |
|
1314 | 1317 | continue; |
|
1315 | head = PyLong_FromSsize_t(i); | |
|
1316 | if (head == NULL || PyList_Append(heads, head) == -1) { | |
|
1317 | Py_XDECREF(head); | |
|
1318 | if (pylist_append_owned(heads, PyLong_FromSsize_t(i)) == -1) { | |
|
1318 | 1319 | goto bail; |
|
1319 | 1320 | } |
|
1320 | 1321 | } |
@@ -1561,15 +1562,9 b' static PyObject *index_deltachain(indexO' | |||
|
1561 | 1562 | iterrev = rev; |
|
1562 | 1563 | |
|
1563 | 1564 | while (iterrev != baserev && iterrev != stoprev) { |
|
1564 | PyObject *value = PyLong_FromLong(iterrev); | |
|
1565 | if (value == NULL) { | |
|
1565 | if (pylist_append_owned(chain, PyLong_FromLong(iterrev))) { | |
|
1566 | 1566 | goto bail; |
|
1567 | 1567 | } |
|
1568 | if (PyList_Append(chain, value)) { | |
|
1569 | Py_DECREF(value); | |
|
1570 | goto bail; | |
|
1571 | } | |
|
1572 | Py_DECREF(value); | |
|
1573 | 1568 | |
|
1574 | 1569 | if (generaldelta) { |
|
1575 | 1570 | iterrev = baserev; |
@@ -1600,15 +1595,9 b' static PyObject *index_deltachain(indexO' | |||
|
1600 | 1595 | if (iterrev == stoprev) { |
|
1601 | 1596 | stopped = 1; |
|
1602 | 1597 | } else { |
|
1603 | PyObject *value = PyLong_FromLong(iterrev); | |
|
1604 | if (value == NULL) { | |
|
1598 | if (pylist_append_owned(chain, PyLong_FromLong(iterrev))) { | |
|
1605 | 1599 | goto bail; |
|
1606 | 1600 | } |
|
1607 | if (PyList_Append(chain, value)) { | |
|
1608 | Py_DECREF(value); | |
|
1609 | goto bail; | |
|
1610 | } | |
|
1611 | Py_DECREF(value); | |
|
1612 | 1601 | |
|
1613 | 1602 | stopped = 0; |
|
1614 | 1603 | } |
@@ -1727,7 +1716,6 b' static PyObject *index_slicechunktodensi' | |||
|
1727 | 1716 | 0; /* total number of notable gap recorded so far */ |
|
1728 | 1717 | Py_ssize_t *selected_indices = NULL; /* indices of gap skipped over */ |
|
1729 | 1718 | Py_ssize_t num_selected = 0; /* number of gaps skipped */ |
|
1730 | PyObject *chunk = NULL; /* individual slice */ | |
|
1731 | 1719 | PyObject *allchunks = NULL; /* all slices */ |
|
1732 | 1720 | Py_ssize_t previdx; |
|
1733 | 1721 | |
@@ -1872,15 +1860,11 b' static PyObject *index_slicechunktodensi' | |||
|
1872 | 1860 | goto bail; |
|
1873 | 1861 | } |
|
1874 | 1862 | if (previdx < endidx) { |
|
1875 | chunk = PyList_GetSlice(list_revs, previdx, endidx); | |
|
1876 | if (chunk == NULL) { | |
|
1863 | PyObject *chunk = | |
|
1864 | PyList_GetSlice(list_revs, previdx, endidx); | |
|
1865 | if (pylist_append_owned(allchunks, chunk) == -1) { | |
|
1877 | 1866 | goto bail; |
|
1878 | 1867 | } |
|
1879 | if (PyList_Append(allchunks, chunk) == -1) { | |
|
1880 | goto bail; | |
|
1881 | } | |
|
1882 | Py_DECREF(chunk); | |
|
1883 | chunk = NULL; | |
|
1884 | 1868 | } |
|
1885 | 1869 | previdx = idx; |
|
1886 | 1870 | } |
@@ -1889,7 +1873,6 b' static PyObject *index_slicechunktodensi' | |||
|
1889 | 1873 | |
|
1890 | 1874 | bail: |
|
1891 | 1875 | Py_XDECREF(allchunks); |
|
1892 | Py_XDECREF(chunk); | |
|
1893 | 1876 | done: |
|
1894 | 1877 | free(revs); |
|
1895 | 1878 | free(gaps); |
@@ -2534,11 +2517,8 b' static PyObject *find_gca_candidates(ind' | |||
|
2534 | 2517 | if (sv < poison) { |
|
2535 | 2518 | interesting -= 1; |
|
2536 | 2519 | if (sv == allseen) { |
|
2537 | PyObject *obj = PyLong_FromLong(v); | |
|
2538 | if (obj == NULL) | |
|
2539 | goto bail; | |
|
2540 | if (PyList_Append(gca, obj) == -1) { | |
|
2541 | Py_DECREF(obj); | |
|
2520 | if (pylist_append_owned( | |
|
2521 | gca, PyLong_FromLong(v)) == -1) { | |
|
2542 | 2522 | goto bail; |
|
2543 | 2523 | } |
|
2544 | 2524 | sv |= poison; |
General Comments 0
You need to be logged in to leave comments.
Login now