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