diff options
Diffstat (limited to 'Include/object.h')
-rw-r--r-- | Include/object.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Include/object.h b/Include/object.h index 2a6b170..ab270f8 100644 --- a/Include/object.h +++ b/Include/object.h @@ -198,6 +198,13 @@ typedef struct _typeobject { /* More standard operations (at end for binary compatibility) */ long (*tp_hash) FPROTO((object *)); +#ifdef COUNT_ALLOCS + /* these must be last */ + int tp_alloc; + int tp_free; + int tp_maxalloc; + struct _typeobject *tp_next; +#endif } typeobject; extern typeobject Typetype; /* The type of type objects */ @@ -253,15 +260,27 @@ environment the global variable trick is not safe.) #endif #ifndef TRACE_REFS +#ifdef COUNT_ALLOCS +#define DELREF(op) ((op)->ob_type->tp_free++, (*(op)->ob_type->tp_dealloc)((object *)(op))) +#else #define DELREF(op) (*(op)->ob_type->tp_dealloc)((object *)(op)) +#endif #define UNREF(op) /*empty*/ #endif +#ifdef COUNT_ALLOCS +extern void inc_count PROTO((typeobject *)); +#endif + #ifdef REF_DEBUG extern long ref_total; #ifndef TRACE_REFS +#ifdef COUNT_ALLOCS +#define NEWREF(op) (inc_count((op)->ob_type), ref_total++, (op)->ob_refcnt = 1) +#else #define NEWREF(op) (ref_total++, (op)->ob_refcnt = 1) #endif +#endif #define INCREF(op) (ref_total++, (op)->ob_refcnt++) #define DECREF(op) \ if (--ref_total, --(op)->ob_refcnt > 0) \ @@ -269,7 +288,11 @@ extern long ref_total; else \ DELREF(op) #else +#ifdef COUNT_ALLOCS +#define NEWREF(op) (inc_count((op)->ob_type), (op)->ob_refcnt = 1) +#else #define NEWREF(op) ((op)->ob_refcnt = 1) +#endif #define INCREF(op) ((op)->ob_refcnt++) #define DECREF(op) \ if (--(op)->ob_refcnt > 0) \ |