comparison mercurial/parsers.c @ 21730:8da100383dc3 stable

parsers.c: fix a couple of memory leaks
author Danek Duvall <danek.duvall@oracle.com>
date Wed, 11 Jun 2014 15:31:04 -0700
parents 628c16489d1c
children 05bd2667df4d
comparison
equal deleted inserted replaced
21709:14560418856d 21730:8da100383dc3
1297 { 1297 {
1298 const Py_ssize_t revcount = PyList_GET_SIZE(revs); 1298 const Py_ssize_t revcount = PyList_GET_SIZE(revs);
1299 static const Py_ssize_t capacity = 24; 1299 static const Py_ssize_t capacity = 24;
1300 int *depth, *interesting = NULL; 1300 int *depth, *interesting = NULL;
1301 int i, j, v, ninteresting; 1301 int i, j, v, ninteresting;
1302 PyObject *dict = NULL, *keys; 1302 PyObject *dict = NULL, *keys = NULL;
1303 long *seen = NULL; 1303 long *seen = NULL;
1304 int maxrev = -1; 1304 int maxrev = -1;
1305 long final; 1305 long final;
1306 1306
1307 if (revcount > capacity) { 1307 if (revcount > capacity) {
1401 if (interesting[i] == 0) 1401 if (interesting[i] == 0)
1402 continue; 1402 continue;
1403 final |= i; 1403 final |= i;
1404 j -= 1; 1404 j -= 1;
1405 } 1405 }
1406 if (final == 0) 1406 if (final == 0) {
1407 return PyList_New(0); 1407 keys = PyList_New(0);
1408 goto bail;
1409 }
1408 1410
1409 dict = PyDict_New(); 1411 dict = PyDict_New();
1410 if (dict == NULL) 1412 if (dict == NULL)
1411 goto bail; 1413 goto bail;
1412 1414
1426 } 1428 }
1427 } 1429 }
1428 1430
1429 keys = PyDict_Keys(dict); 1431 keys = PyDict_Keys(dict);
1430 1432
1431 free(depth);
1432 free(seen);
1433 free(interesting);
1434 Py_DECREF(dict);
1435
1436 return keys;
1437 bail: 1433 bail:
1438 free(depth); 1434 free(depth);
1439 free(seen); 1435 free(seen);
1440 free(interesting); 1436 free(interesting);
1441 Py_XDECREF(dict); 1437 Py_XDECREF(dict);
1442 1438
1443 return NULL; 1439 return keys;
1444 } 1440 }
1445 1441
1446 /* 1442 /*
1447 * Given a (possibly overlapping) set of revs, return the greatest 1443 * Given a (possibly overlapping) set of revs, return the greatest
1448 * common ancestors: those with the longest path to the root. 1444 * common ancestors: those with the longest path to the root.