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); |