Mercurial > cpython-lru_cache-weakref
annotate Include/tupleobject.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 | 9e4d1a6307f6 |
| children | c1eb668525e1 |
| rev | line source |
|---|---|
| 145 | 1 |
| 6 | 2 /* Tuple object interface */ |
| 3 | |
|
13445
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
4 #ifndef Py_TUPLEOBJECT_H |
|
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
5 #define Py_TUPLEOBJECT_H |
|
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
6 #ifdef __cplusplus |
|
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
7 extern "C" { |
|
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
8 #endif |
|
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
9 |
| 6 | 10 /* |
| 11 Another generally useful object type is an tuple of object pointers. | |
| 12 This is a mutable type: the tuple items can be changed (but not their | |
| 13 number). Out-of-range indices or non-tuple objects are ignored. | |
| 14 | |
|
2129
05360cd616ae
The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents:
2058
diff
changeset
|
15 *** WARNING *** PyTuple_SetItem does not increment the new item's reference |
| 6 | 16 count, but does decrement the reference count of the item it replaces, |
| 17 if not nil. It does *decrement* the reference count if it is *not* | |
|
2129
05360cd616ae
The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents:
2058
diff
changeset
|
18 inserted in the tuple. Similarly, PyTuple_GetItem does not increment the |
| 6 | 19 returned item's reference count. |
| 20 */ | |
| 21 | |
| 86 | 22 typedef struct { |
|
13445
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
23 PyObject_VAR_HEAD |
|
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
24 PyObject *ob_item[1]; |
|
2129
05360cd616ae
The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents:
2058
diff
changeset
|
25 } PyTupleObject; |
| 86 | 26 |
|
2669
34eefa226709
DL_IMPORT needs an argument.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2664
diff
changeset
|
27 extern DL_IMPORT(PyTypeObject) PyTuple_Type; |
| 6 | 28 |
|
19589
844553473fa4
Make the Py<type>_Check() macro use PyObject_TypeCheck().
Guido van Rossum <guido@python.org>
parents:
17976
diff
changeset
|
29 #define PyTuple_Check(op) PyObject_TypeCheck(op, &PyTuple_Type) |
|
19844
9e4d1a6307f6
More on SF bug [#460020] bug or feature: unicode() and subclasses.
Tim Peters <tim.peters@gmail.com>
parents:
19589
diff
changeset
|
30 #define PyTuple_CheckExact(op) ((op)->ob_type == &PyTuple_Type) |
| 6 | 31 |
|
13445
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
32 extern DL_IMPORT(PyObject *) PyTuple_New(int size); |
|
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
33 extern DL_IMPORT(int) PyTuple_Size(PyObject *); |
|
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
34 extern DL_IMPORT(PyObject *) PyTuple_GetItem(PyObject *, int); |
|
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
35 extern DL_IMPORT(int) PyTuple_SetItem(PyObject *, int, PyObject *); |
|
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
36 extern DL_IMPORT(PyObject *) PyTuple_GetSlice(PyObject *, int, int); |
|
17976
d579a5d8b3fe
Cruft cleanup: Removed the unused last_is_sticky argument from the internal
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
37 extern DL_IMPORT(int) _PyTuple_Resize(PyObject **, int); |
| 86 | 38 |
| 39 /* Macro, trading safety for speed */ | |
|
2500
f217c1b27f86
addet SETTUPLEITEM and added cast to GETTUPLEITEM
Guido van Rossum <guido@python.org>
parents:
2436
diff
changeset
|
40 #define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i]) |
|
4898
4f87fd2d0562
added PyTuple_GET_SIZE macro
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
41 #define PyTuple_GET_SIZE(op) (((PyTupleObject *)(op))->ob_size) |
|
2500
f217c1b27f86
addet SETTUPLEITEM and added cast to GETTUPLEITEM
Guido van Rossum <guido@python.org>
parents:
2436
diff
changeset
|
42 |
|
f217c1b27f86
addet SETTUPLEITEM and added cast to GETTUPLEITEM
Guido van Rossum <guido@python.org>
parents:
2436
diff
changeset
|
43 /* Macro, *only* to be used to fill in brand new tuples */ |
|
f217c1b27f86
addet SETTUPLEITEM and added cast to GETTUPLEITEM
Guido van Rossum <guido@python.org>
parents:
2436
diff
changeset
|
44 #define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v) |
|
1329
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
45 |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
46 #ifdef __cplusplus |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
47 } |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
48 #endif |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
49 #endif /* !Py_TUPLEOBJECT_H */ |
