Show More
@@ -1130,10 +1130,10 b' static PyObject *reachableroots(indexObj' | |||||
1130 |
|
1130 | |||
1131 | /* Internal data structure: |
|
1131 | /* Internal data structure: | |
1132 | * tovisit: array of length len+1 (all revs + nullrev), filled upto lentovisit |
|
1132 | * tovisit: array of length len+1 (all revs + nullrev), filled upto lentovisit | |
1133 |
* |
|
1133 | * revstates: array of length len+1 (all revs + nullrev) 0: not seen, 1 seen*/ | |
1134 | int *tovisit = NULL; |
|
1134 | int *tovisit = NULL; | |
1135 | long lentovisit = 0; |
|
1135 | long lentovisit = 0; | |
1136 |
char * |
|
1136 | char *revstates = NULL; | |
1137 |
|
1137 | |||
1138 | /* Get arguments */ |
|
1138 | /* Get arguments */ | |
1139 | if (!PyArg_ParseTuple(args, "lO!O!O!", &minroot, &PyList_Type, &heads, |
|
1139 | if (!PyArg_ParseTuple(args, "lO!O!O!", &minroot, &PyList_Type, &heads, | |
@@ -1157,8 +1157,8 b' static PyObject *reachableroots(indexObj' | |||||
1157 | goto bail; |
|
1157 | goto bail; | |
1158 | } |
|
1158 | } | |
1159 |
|
1159 | |||
1160 |
|
|
1160 | revstates = (char *)calloc(len + 1, 1); | |
1161 |
if ( |
|
1161 | if (revstates == NULL) { | |
1162 | PyErr_NoMemory(); |
|
1162 | PyErr_NoMemory(); | |
1163 | goto bail; |
|
1163 | goto bail; | |
1164 | } |
|
1164 | } | |
@@ -1173,9 +1173,9 b' static PyObject *reachableroots(indexObj' | |||||
1173 | PyErr_SetString(PyExc_IndexError, "head out of range"); |
|
1173 | PyErr_SetString(PyExc_IndexError, "head out of range"); | |
1174 | goto bail; |
|
1174 | goto bail; | |
1175 | } |
|
1175 | } | |
1176 |
if ( |
|
1176 | if (revstates[revnum+1] == 0) { | |
1177 | tovisit[lentovisit++] = revnum; |
|
1177 | tovisit[lentovisit++] = revnum; | |
1178 |
|
|
1178 | revstates[revnum+1]=1; | |
1179 | } |
|
1179 | } | |
1180 | } |
|
1180 | } | |
1181 |
|
1181 | |||
@@ -1203,10 +1203,10 b' static PyObject *reachableroots(indexObj' | |||||
1203 | if (r < 0) |
|
1203 | if (r < 0) | |
1204 | goto bail; |
|
1204 | goto bail; | |
1205 | for (i = 0; i < 2; i++) { |
|
1205 | for (i = 0; i < 2; i++) { | |
1206 |
if ( |
|
1206 | if (revstates[parents[i] + 1] == 0 | |
1207 | && parents[i] >= minroot) { |
|
1207 | && parents[i] >= minroot) { | |
1208 | tovisit[lentovisit++] = parents[i]; |
|
1208 | tovisit[lentovisit++] = parents[i]; | |
1209 |
|
|
1209 | revstates[parents[i] + 1] = 1; | |
1210 | } |
|
1210 | } | |
1211 | } |
|
1211 | } | |
1212 | } |
|
1212 | } | |
@@ -1218,7 +1218,7 b' static PyObject *reachableroots(indexObj' | |||||
1218 | if (minidx < 0) |
|
1218 | if (minidx < 0) | |
1219 | minidx = 0; |
|
1219 | minidx = 0; | |
1220 | for (i = minidx; i < len; i++) { |
|
1220 | for (i = minidx; i < len; i++) { | |
1221 |
if ( |
|
1221 | if (revstates[i + 1] != 1) | |
1222 | continue; |
|
1222 | continue; | |
1223 | r = index_get_parents(self, i, parents, (int)len - 1); |
|
1223 | r = index_get_parents(self, i, parents, (int)len - 1); | |
1224 | /* Corrupted index file, error is set from |
|
1224 | /* Corrupted index file, error is set from | |
@@ -1241,12 +1241,12 b' static PyObject *reachableroots(indexObj' | |||||
1241 | } |
|
1241 | } | |
1242 | } |
|
1242 | } | |
1243 |
|
1243 | |||
1244 |
free( |
|
1244 | free(revstates); | |
1245 | free(tovisit); |
|
1245 | free(tovisit); | |
1246 | return reachable; |
|
1246 | return reachable; | |
1247 | bail: |
|
1247 | bail: | |
1248 | Py_XDECREF(reachable); |
|
1248 | Py_XDECREF(reachable); | |
1249 |
free( |
|
1249 | free(revstates); | |
1250 | free(tovisit); |
|
1250 | free(tovisit); | |
1251 | return NULL; |
|
1251 | return NULL; | |
1252 | } |
|
1252 | } |
General Comments 0
You need to be logged in to leave comments.
Login now