mercurial/parsers.c
changeset 20111 9bfa86746c9c
parent 20110 40b7c6e4b993
parent 20109 e57c532c3835
child 20155 21dafd8546d1
equal deleted inserted replaced
20110:40b7c6e4b993 20111:9bfa86746c9c
  1716 static int index_init(indexObject *self, PyObject *args)
  1716 static int index_init(indexObject *self, PyObject *args)
  1717 {
  1717 {
  1718 	PyObject *data_obj, *inlined_obj;
  1718 	PyObject *data_obj, *inlined_obj;
  1719 	Py_ssize_t size;
  1719 	Py_ssize_t size;
  1720 
  1720 
       
  1721 	/* Initialize before argument-checking to avoid index_dealloc() crash. */
       
  1722 	self->raw_length = 0;
       
  1723 	self->added = NULL;
       
  1724 	self->cache = NULL;
       
  1725 	self->data = NULL;
       
  1726 	self->headrevs = NULL;
       
  1727 	self->nt = NULL;
       
  1728 	self->offsets = NULL;
       
  1729 
  1721 	if (!PyArg_ParseTuple(args, "OO", &data_obj, &inlined_obj))
  1730 	if (!PyArg_ParseTuple(args, "OO", &data_obj, &inlined_obj))
  1722 		return -1;
  1731 		return -1;
  1723 	if (!PyString_Check(data_obj)) {
  1732 	if (!PyString_Check(data_obj)) {
  1724 		PyErr_SetString(PyExc_TypeError, "data is not a string");
  1733 		PyErr_SetString(PyExc_TypeError, "data is not a string");
  1725 		return -1;
  1734 		return -1;
  1726 	}
  1735 	}
  1727 	size = PyString_GET_SIZE(data_obj);
  1736 	size = PyString_GET_SIZE(data_obj);
  1728 
  1737 
  1729 	self->inlined = inlined_obj && PyObject_IsTrue(inlined_obj);
  1738 	self->inlined = inlined_obj && PyObject_IsTrue(inlined_obj);
  1730 	self->data = data_obj;
  1739 	self->data = data_obj;
  1731 	self->cache = NULL;
  1740 
  1732 
       
  1733 	self->added = NULL;
       
  1734 	self->headrevs = NULL;
       
  1735 	self->offsets = NULL;
       
  1736 	self->nt = NULL;
       
  1737 	self->ntlength = self->ntcapacity = 0;
  1741 	self->ntlength = self->ntcapacity = 0;
  1738 	self->ntdepth = self->ntsplits = 0;
  1742 	self->ntdepth = self->ntsplits = 0;
  1739 	self->ntlookups = self->ntmisses = 0;
  1743 	self->ntlookups = self->ntmisses = 0;
  1740 	self->ntrev = -1;
  1744 	self->ntrev = -1;
  1741 	Py_INCREF(self->data);
  1745 	Py_INCREF(self->data);
  1767 }
  1771 }
  1768 
  1772 
  1769 static void index_dealloc(indexObject *self)
  1773 static void index_dealloc(indexObject *self)
  1770 {
  1774 {
  1771 	_index_clearcaches(self);
  1775 	_index_clearcaches(self);
  1772 	Py_DECREF(self->data);
  1776 	Py_XDECREF(self->data);
  1773 	Py_XDECREF(self->added);
  1777 	Py_XDECREF(self->added);
  1774 	PyObject_Del(self);
  1778 	PyObject_Del(self);
  1775 }
  1779 }
  1776 
  1780 
  1777 static PySequenceMethods index_sequence_methods = {
  1781 static PySequenceMethods index_sequence_methods = {