mercurial/parsers.c
branchstable
changeset 20109 e57c532c3835
parent 19728 3daabd2da78b
child 20111 9bfa86746c9c
child 20167 09e41ac6289d
equal deleted inserted replaced
20107:2ca325ea57fa 20109:e57c532c3835
  1711 static int index_init(indexObject *self, PyObject *args)
  1711 static int index_init(indexObject *self, PyObject *args)
  1712 {
  1712 {
  1713 	PyObject *data_obj, *inlined_obj;
  1713 	PyObject *data_obj, *inlined_obj;
  1714 	Py_ssize_t size;
  1714 	Py_ssize_t size;
  1715 
  1715 
       
  1716 	/* Initialize before argument-checking to avoid index_dealloc() crash. */
       
  1717 	self->raw_length = 0;
       
  1718 	self->added = NULL;
       
  1719 	self->cache = NULL;
       
  1720 	self->data = NULL;
       
  1721 	self->headrevs = NULL;
       
  1722 	self->nt = NULL;
       
  1723 	self->offsets = NULL;
       
  1724 
  1716 	if (!PyArg_ParseTuple(args, "OO", &data_obj, &inlined_obj))
  1725 	if (!PyArg_ParseTuple(args, "OO", &data_obj, &inlined_obj))
  1717 		return -1;
  1726 		return -1;
  1718 	if (!PyString_Check(data_obj)) {
  1727 	if (!PyString_Check(data_obj)) {
  1719 		PyErr_SetString(PyExc_TypeError, "data is not a string");
  1728 		PyErr_SetString(PyExc_TypeError, "data is not a string");
  1720 		return -1;
  1729 		return -1;
  1721 	}
  1730 	}
  1722 	size = PyString_GET_SIZE(data_obj);
  1731 	size = PyString_GET_SIZE(data_obj);
  1723 
  1732 
  1724 	self->inlined = inlined_obj && PyObject_IsTrue(inlined_obj);
  1733 	self->inlined = inlined_obj && PyObject_IsTrue(inlined_obj);
  1725 	self->data = data_obj;
  1734 	self->data = data_obj;
  1726 	self->cache = NULL;
  1735 
  1727 
       
  1728 	self->added = NULL;
       
  1729 	self->headrevs = NULL;
       
  1730 	self->offsets = NULL;
       
  1731 	self->nt = NULL;
       
  1732 	self->ntlength = self->ntcapacity = 0;
  1736 	self->ntlength = self->ntcapacity = 0;
  1733 	self->ntdepth = self->ntsplits = 0;
  1737 	self->ntdepth = self->ntsplits = 0;
  1734 	self->ntlookups = self->ntmisses = 0;
  1738 	self->ntlookups = self->ntmisses = 0;
  1735 	self->ntrev = -1;
  1739 	self->ntrev = -1;
  1736 	Py_INCREF(self->data);
  1740 	Py_INCREF(self->data);
  1762 }
  1766 }
  1763 
  1767 
  1764 static void index_dealloc(indexObject *self)
  1768 static void index_dealloc(indexObject *self)
  1765 {
  1769 {
  1766 	_index_clearcaches(self);
  1770 	_index_clearcaches(self);
  1767 	Py_DECREF(self->data);
  1771 	Py_XDECREF(self->data);
  1768 	Py_XDECREF(self->added);
  1772 	Py_XDECREF(self->added);
  1769 	PyObject_Del(self);
  1773 	PyObject_Del(self);
  1770 }
  1774 }
  1771 
  1775 
  1772 static PySequenceMethods index_sequence_methods = {
  1776 static PySequenceMethods index_sequence_methods = {