Mercurial > cpython-lru_cache-weakref
diff Include/objimpl.h @ 13265:e8bb0d536633 legacy-trunk
Neil Schemenauer: small fixes for GC
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Sat, 01 Jul 2000 01:00:38 +0000 |
| parents | 87ee82e5c56d |
| children | 091ca6b9348f |
line wrap: on
line diff
--- a/Include/objimpl.h Sat Jul 01 00:51:51 2000 +0000 +++ b/Include/objimpl.h Sat Jul 01 01:00:38 2000 +0000 @@ -183,6 +183,8 @@ (PyVarObject *) PyObject_MALLOC( _PyObject_VAR_SIZE((typeobj),(n)) ),\ (typeobj), (n)) ) +#define PyObject_DEL(op) PyObject_FREE(op) + /* This example code implements an object constructor with a custom allocator, where PyObject_New is inlined, and shows the important distinction between two steps (at least): @@ -221,7 +223,7 @@ PyObject_{New, VarNew, Del} to manage the memory. Set the type flag Py_TPFLAGS_GC and define the type method tp_recurse. You should also add the method tp_clear if your object is mutable. Include - PyGC_INFO_SIZE in the calculation of tp_basicsize. Call + PyGC_HEAD_SIZE in the calculation of tp_basicsize. Call PyObject_GC_Init after the pointers followed by tp_recurse become valid (usually just before returning the object from the allocation method. Call PyObject_GC_Fini before those pointers become invalid @@ -234,7 +236,6 @@ #define PyObject_GC_Fini(op) #define PyObject_AS_GC(op) (op) #define PyObject_FROM_GC(op) (op) -#define PyObject_DEL(op) PyObject_FREE(op) #else @@ -268,10 +269,6 @@ /* Get the object given the PyGC_Head */ #define PyObject_FROM_GC(g) ((PyObject *)(((PyGC_Head *)g)+1)) -#define PyObject_DEL(op) PyObject_FREE( PyObject_IS_GC(op) ? \ - (ANY *)PyObject_AS_GC(op) : \ - (ANY *)(op) ) - #endif /* WITH_CYCLE_GC */ #ifdef __cplusplus
