• Home
  • Raw
  • Download

Lines Matching full:extra

22 /* An element can hold this many children without extra memory
211 ElementObjectExtra* extra; member
228 self->extra = PyObject_Malloc(sizeof(ElementObjectExtra)); in create_extra()
229 if (!self->extra) { in create_extra()
235 self->extra->attrib = attrib; in create_extra()
237 self->extra->length = 0; in create_extra()
238 self->extra->allocated = STATIC_CHILDREN; in create_extra()
239 self->extra->children = self->extra->_children; in create_extra()
245 dealloc_extra(ElementObjectExtra *extra) in dealloc_extra() argument
249 if (!extra) in dealloc_extra()
252 Py_XDECREF(extra->attrib); in dealloc_extra()
254 for (i = 0; i < extra->length; i++) in dealloc_extra()
255 Py_DECREF(extra->children[i]); in dealloc_extra()
257 if (extra->children != extra->_children) in dealloc_extra()
258 PyObject_Free(extra->children); in dealloc_extra()
260 PyObject_Free(extra); in dealloc_extra()
268 if (!self->extra) in clear_extra()
273 myextra = self->extra; in clear_extra()
274 self->extra = NULL; in clear_extra()
290 self->extra = NULL; in create_new_element()
330 e->extra = NULL; in element_new()
444 element_resize(ElementObject* self, Py_ssize_t extra) in element_resize() argument
449 assert(extra >= 0); in element_resize()
450 /* make sure self->children can hold the given number of extra in element_resize()
453 if (!self->extra) { in element_resize()
458 size = self->extra->length + extra; /* never overflows */ in element_resize()
460 if (size > self->extra->allocated) { in element_resize()
471 if (self->extra->children != self->extra->_children) { in element_resize()
476 children = PyObject_Realloc(self->extra->children, in element_resize()
485 memcpy(children, self->extra->children, in element_resize()
486 self->extra->length * sizeof(PyObject*)); in element_resize()
488 self->extra->children = children; in element_resize()
489 self->extra->allocated = size; in element_resize()
521 self->extra->children[self->extra->length] = element; in element_add_subelement()
523 self->extra->length++; in element_add_subelement()
532 /* note: this function assumes that the extra section exists */ in element_get_attrib()
534 PyObject* res = self->extra->attrib; in element_get_attrib()
538 res = self->extra->attrib = PyDict_New(); in element_get_attrib()
640 if (self->extra) { in element_gc_traverse()
642 Py_VISIT(self->extra->attrib); in element_gc_traverse()
644 for (i = 0; i < self->extra->length; ++i) in element_gc_traverse()
645 Py_VISIT(self->extra->children[i]); in element_gc_traverse()
657 /* After dropping all references from extra, it's no longer valid anyway, in element_gc_clear()
674 /* element_gc_clear clears all references and deallocates extra in element_dealloc()
736 self->tag, self->extra ? self->extra->attrib : NULL); in _elementtree_Element___copy___impl()
746 assert(!element->extra || !element->extra->length); in _elementtree_Element___copy___impl()
747 if (self->extra) { in _elementtree_Element___copy___impl()
748 if (element_resize(element, self->extra->length) < 0) { in _elementtree_Element___copy___impl()
753 for (i = 0; i < self->extra->length; i++) { in _elementtree_Element___copy___impl()
754 Py_INCREF(self->extra->children[i]); in _elementtree_Element___copy___impl()
755 element->extra->children[i] = self->extra->children[i]; in _elementtree_Element___copy___impl()
758 assert(!element->extra->length); in _elementtree_Element___copy___impl()
759 element->extra->length = self->extra->length; in _elementtree_Element___copy___impl()
792 if (self->extra && self->extra->attrib) { in _elementtree_Element___deepcopy___impl()
793 attrib = deepcopy(self->extra->attrib, memo); in _elementtree_Element___deepcopy___impl()
820 assert(!element->extra || !element->extra->length); in _elementtree_Element___deepcopy___impl()
821 if (self->extra) { in _elementtree_Element___deepcopy___impl()
822 if (element_resize(element, self->extra->length) < 0) in _elementtree_Element___deepcopy___impl()
825 for (i = 0; i < self->extra->length; i++) { in _elementtree_Element___deepcopy___impl()
826 PyObject* child = deepcopy(self->extra->children[i], memo); in _elementtree_Element___deepcopy___impl()
832 element->extra->length = i; in _elementtree_Element___deepcopy___impl()
835 element->extra->children[i] = child; in _elementtree_Element___deepcopy___impl()
838 assert(!element->extra->length); in _elementtree_Element___deepcopy___impl()
839 element->extra->length = self->extra->length; in _elementtree_Element___deepcopy___impl()
919 if (self->extra) { in _elementtree_Element___sizeof___impl()
921 if (self->extra->children != self->extra->_children) in _elementtree_Element___sizeof___impl()
922 result += sizeof(PyObject*) * self->extra->allocated; in _elementtree_Element___sizeof___impl()
953 children = PyList_New(self->extra ? self->extra->length : 0); in _elementtree_Element___getstate___impl()
957 PyObject *child = self->extra->children[i]; in _elementtree_Element___getstate___impl()
962 if (self->extra && self->extra->attrib) { in _elementtree_Element___getstate___impl()
963 attrib = self->extra->attrib; in _elementtree_Element___getstate___impl()
1022 /* (Re-)allocate 'extra'. in element_setstate_from_attributes()
1025 oldextra = self->extra; in element_setstate_from_attributes()
1026 self->extra = NULL; in element_setstate_from_attributes()
1028 assert(!self->extra || !self->extra->length); in element_setstate_from_attributes()
1030 self->extra = oldextra; in element_setstate_from_attributes()
1033 assert(self->extra); in element_setstate_from_attributes()
1034 assert(self->extra->allocated >= nchildren); in element_setstate_from_attributes()
1036 assert(self->extra->attrib == NULL); in element_setstate_from_attributes()
1037 self->extra->attrib = oldextra->attrib; in element_setstate_from_attributes()
1046 self->extra->length = i; in element_setstate_from_attributes()
1051 self->extra->children[i] = child; in element_setstate_from_attributes()
1054 assert(!self->extra->length); in element_setstate_from_attributes()
1055 self->extra->length = nchildren; in element_setstate_from_attributes()
1065 Py_XSETREF(self->extra->attrib, attrib); in element_setstate_from_attributes()
1240 if (!self->extra) in _elementtree_Element_find_impl()
1243 for (i = 0; i < self->extra->length; i++) { in _elementtree_Element_find_impl()
1244 PyObject* item = self->extra->children[i]; in _elementtree_Element_find_impl()
1284 if (!self->extra) { in _elementtree_Element_findtext_impl()
1289 for (i = 0; i < self->extra->length; i++) { in _elementtree_Element_findtext_impl()
1290 PyObject *item = self->extra->children[i]; in _elementtree_Element_findtext_impl()
1342 if (!self->extra) in _elementtree_Element_findall_impl()
1345 for (i = 0; i < self->extra->length; i++) { in _elementtree_Element_findall_impl()
1346 PyObject* item = self->extra->children[i]; in _elementtree_Element_findall_impl()
1396 if (self->extra && self->extra->attrib) { in _elementtree_Element_get_impl()
1397 PyObject *attrib = self->extra->attrib; in _elementtree_Element_get_impl()
1459 if (!self->extra || index < 0 || index >= self->extra->length) { in element_getitem()
1467 Py_INCREF(self->extra->children[index]); in element_getitem()
1468 return self->extra->children[index]; in element_getitem()
1487 if (!self->extra) { in _elementtree_Element_insert_impl()
1493 index += self->extra->length; in _elementtree_Element_insert_impl()
1497 if (index > self->extra->length) in _elementtree_Element_insert_impl()
1498 index = self->extra->length; in _elementtree_Element_insert_impl()
1503 for (i = self->extra->length; i > index; i--) in _elementtree_Element_insert_impl()
1504 self->extra->children[i] = self->extra->children[i-1]; in _elementtree_Element_insert_impl()
1507 self->extra->children[index] = subelement; in _elementtree_Element_insert_impl()
1509 self->extra->length++; in _elementtree_Element_insert_impl()
1523 if (!self->extra || !self->extra->attrib) in _elementtree_Element_items_impl()
1526 return PyDict_Items(self->extra->attrib); in _elementtree_Element_items_impl()
1538 if (!self->extra || !self->extra->attrib) in _elementtree_Element_keys_impl()
1541 return PyDict_Keys(self->extra->attrib); in _elementtree_Element_keys_impl()
1547 if (!self->extra) in element_length()
1550 return self->extra->length; in element_length()
1596 if (!self->extra) { in _elementtree_Element_remove_impl()
1605 for (i = 0; i < self->extra->length; i++) { in _elementtree_Element_remove_impl()
1606 if (self->extra->children[i] == subelement) in _elementtree_Element_remove_impl()
1608 rc = PyObject_RichCompareBool(self->extra->children[i], subelement, Py_EQ); in _elementtree_Element_remove_impl()
1615 if (i >= self->extra->length) { in _elementtree_Element_remove_impl()
1624 found = self->extra->children[i]; in _elementtree_Element_remove_impl()
1626 self->extra->length--; in _elementtree_Element_remove_impl()
1627 for (; i < self->extra->length; i++) in _elementtree_Element_remove_impl()
1628 self->extra->children[i] = self->extra->children[i+1]; in _elementtree_Element_remove_impl()
1672 if (!self->extra) { in _elementtree_Element_set_impl()
1694 if (!self->extra || index < 0 || index >= self->extra->length) { in element_setitem()
1701 old = self->extra->children[index]; in element_setitem()
1709 self->extra->children[index] = item; in element_setitem()
1711 self->extra->length--; in element_setitem()
1712 for (i = index; i < self->extra->length; i++) in element_setitem()
1713 self->extra->children[i] = self->extra->children[i+1]; in element_setitem()
1732 if (i < 0 && self->extra) in element_subscr()
1733 i += self->extra->length; in element_subscr()
1741 if (!self->extra) in element_subscr()
1747 slicelen = PySlice_AdjustIndices(self->extra->length, &start, &stop, in element_subscr()
1759 PyObject* item = self->extra->children[cur]; in element_subscr()
1785 if (i < 0 && self->extra) in element_ass_subscr()
1786 i += self->extra->length; in element_ass_subscr()
1796 if (!self->extra) { in element_ass_subscr()
1804 slicelen = PySlice_AdjustIndices(self->extra->length, &start, &stop, in element_ass_subscr()
1845 if (cur + step >= (size_t)self->extra->length) { in element_ass_subscr()
1846 num_moved = self->extra->length - cur - 1; in element_ass_subscr()
1849 PyList_SET_ITEM(recycle, i, self->extra->children[cur]); in element_ass_subscr()
1852 self->extra->children + cur - i, in element_ass_subscr()
1853 self->extra->children + cur + 1, in element_ass_subscr()
1859 if (cur < (size_t)self->extra->length) { in element_ass_subscr()
1861 self->extra->children + cur - slicelen, in element_ass_subscr()
1862 self->extra->children + cur, in element_ass_subscr()
1863 (self->extra->length - cur) * sizeof(PyObject *)); in element_ass_subscr()
1866 self->extra->length -= slicelen; in element_ass_subscr()
1923 PyList_SET_ITEM(recycle, i, self->extra->children[cur]); in element_ass_subscr()
1928 for (i = stop; i < self->extra->length; i++) in element_ass_subscr()
1929 self->extra->children[i + newlen - slicelen] = self->extra->children[i]; in element_ass_subscr()
1932 for (i = self->extra->length-1; i >= stop; i--) in element_ass_subscr()
1933 self->extra->children[i + newlen - slicelen] = self->extra->children[i]; in element_ass_subscr()
1941 self->extra->children[cur] = element; in element_ass_subscr()
1944 self->extra->length += newlen - slicelen; in element_ass_subscr()
1988 if (!self->extra) { in element_attrib_getter()
2043 if (!self->extra) { in element_attrib_setter()
2048 Py_XSETREF(self->extra->attrib, value); in element_attrib_setter()
2178 ElementObjectExtra *extra; in elementiter_next() local
2180 extra = elem->extra; in elementiter_next()
2181 if (!extra || child_index >= extra->length) { in elementiter_next()
2183 /* Note that extra condition on it->parent_stack_used here; in elementiter_next()
2195 assert(Element_Check(extra->children[child_index])); in elementiter_next()
2196 elem = (ElementObject *)extra->children[child_index]; in elementiter_next()