[Python-checkins] CVS: python/dist/src/Objects listobject.c,2.92.6.2,2.92.6.3
Guido van Rossum
gvanrossum@users.sourceforge.net
Fri, 04 May 2001 10:12:56 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv32430/Objects
Modified Files:
Tag: descr-branch
listobject.c
Log Message:
Make lists subclassable. Add code that frees ob_item when empty.
Index: listobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v
retrieving revision 2.92.6.2
retrieving revision 2.92.6.3
diff -C2 -r2.92.6.2 -r2.92.6.3
*** listobject.c 2001/04/27 18:04:51 2.92.6.2
--- listobject.c 2001/05/04 17:12:53 2.92.6.3
***************
*** 459,462 ****
--- 459,466 ----
PyMem_DEL(recycle);
}
+ if (a->ob_size == 0 && a->ob_item != NULL) {
+ PyMem_FREE(a->ob_item);
+ a->ob_item = NULL;
+ }
return 0;
#undef b
***************
*** 1491,1494 ****
--- 1495,1508 ----
}
+ static PyObject *
+ list_construct(PyListObject *self)
+ {
+ if (self == NULL)
+ return PyList_New(0);
+ self->ob_size = 0;
+ self->ob_item = NULL;
+ return (PyObject *)self;
+ }
+
static char append_doc[] =
"L.append(object) -- append object to end";
***************
*** 1570,1573 ****
--- 1584,1590 ----
0, /* tp_base */
0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ (unaryfunc)list_construct, /* tp_construct */
};
***************
*** 1650,1653 ****
--- 1667,1673 ----
0, /* tp_base */
0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ (unaryfunc)list_construct, /* tp_construct */
/* NOTE: This is *not* the standard list_type struct! */
};