annotate Include/weakrefobject.h @ 25838:8540887bcec6 2.2

Backport of 2.183: Fix memory leak in add_subclass() found by NealN with valgrind.
author Guido van Rossum <guido@python.org>
date Fri, 18 Oct 2002 13:42:21 +0000
parents f48782237f85
children c1eb668525e1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20280
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
1 /* Weak references objects for Python. */
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
2
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
3 #ifndef Py_WEAKREFOBJECT_H
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
4 #define Py_WEAKREFOBJECT_H
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
5 #ifdef __cplusplus
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
6 extern "C" {
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
7 #endif
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
8
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
9
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
10 typedef struct _PyWeakReference PyWeakReference;
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
11
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
12 struct _PyWeakReference {
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
13 PyObject_HEAD
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
14 PyObject *wr_object;
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
15 PyObject *wr_callback;
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
16 long hash;
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
17 PyWeakReference *wr_prev;
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
18 PyWeakReference *wr_next;
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
19 };
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
20
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
21 extern DL_IMPORT(PyTypeObject) _PyWeakref_RefType;
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
22 extern DL_IMPORT(PyTypeObject) _PyWeakref_ProxyType;
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
23 extern DL_IMPORT(PyTypeObject) _PyWeakref_CallableProxyType;
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
24
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
25 #define PyWeakref_CheckRef(op) \
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
26 ((op)->ob_type == &_PyWeakref_RefType)
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
27 #define PyWeakref_CheckProxy(op) \
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
28 (((op)->ob_type == &_PyWeakref_ProxyType) || \
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
29 ((op)->ob_type == &_PyWeakref_CallableProxyType))
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
30 #define PyWeakref_Check(op) \
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
31 (PyWeakref_CheckRef(op) || PyWeakref_CheckProxy(op))
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
32
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
33
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
34 extern DL_IMPORT(PyObject *) PyWeakref_NewRef(PyObject *ob,
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
35 PyObject *callback);
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
36 extern DL_IMPORT(PyObject *) PyWeakref_NewProxy(PyObject *ob,
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
37 PyObject *callback);
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
38 extern DL_IMPORT(PyObject *) PyWeakref_GetObject(PyObject *ref);
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
39
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
40 extern DL_IMPORT(long) _PyWeakref_GetWeakrefCount(PyWeakReference *head);
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
41
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
42 #define PyWeakref_GET_OBJECT(ref) (((PyWeakReference *)(ref))->wr_object)
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
43
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
44
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
45 #ifdef __cplusplus
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
46 }
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
47 #endif
97cfa461d793 The weak reference implementation, separated from the weakref module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
48 #endif /* !Py_WEAKREFOBJECT_H */