Mercurial > hgrepos > Python > libs > ConfigMix
comparison configmix/_py_helper.h @ 563:2c211934d4b0
Some more helper functions (with regard to NULL PyObjects)
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Thu, 06 Jan 2022 20:37:29 +0100 |
| parents | f75c5b13a1d7 |
| children | f454889e41fa |
comparison
equal
deleted
inserted
replaced
| 562:f75c5b13a1d7 | 563:2c211934d4b0 |
|---|---|
| 80 */ | 80 */ |
| 81 static inline | 81 static inline |
| 82 void | 82 void |
| 83 py_assign(PyObject **dest, PyObject *src) | 83 py_assign(PyObject **dest, PyObject *src) |
| 84 { | 84 { |
| 85 Py_XDECREF(*dest); | 85 Py_DECREF(*dest); |
| 86 *dest = Py_NewRef(src); | 86 *dest = Py_NewRef(src); |
| 87 } | 87 } |
| 88 | 88 |
| 89 | 89 |
| 90 /** | 90 /** |
| 91 * Copy from source to destination and make an owned reference. | 91 * Copy from source to destination and make an owned reference. |
| 92 * Also clear the destination before. | |
| 93 */ | |
| 94 static inline | |
| 95 void | |
| 96 py_x_assign(PyObject **dest, PyObject *src) | |
| 97 { | |
| 98 Py_XDECREF(*dest); | |
| 99 *dest = Py_NewRef(src); | |
| 100 } | |
| 101 | |
| 102 | |
| 103 /** | |
| 104 * Copy from source to destination and make an owned reference. | |
| 105 * Also clear the destination before. The source object may be NULL. | |
| 106 */ | |
| 107 static inline | |
| 108 void | |
| 109 py_assign_x(PyObject **dest, PyObject *src) | |
| 110 { | |
| 111 Py_DECREF(*dest); | |
| 112 *dest = Py_XNewRef(src); | |
| 113 } | |
| 114 | |
| 115 | |
| 116 /** | |
| 117 * Copy from source to destination and make an owned reference. | |
| 92 * Also safely clear the destination before. The source object may be NULL. | 118 * Also safely clear the destination before. The source object may be NULL. |
| 93 */ | 119 */ |
| 94 static inline | 120 static inline |
| 95 void | 121 void |
| 96 py_assign_x(PyObject **dest, PyObject *src) | 122 py_x_assign_x(PyObject **dest, PyObject *src) |
| 97 { | 123 { |
| 98 Py_XDECREF(*dest); | 124 Py_XDECREF(*dest); |
| 99 *dest = Py_XNewRef(src); | 125 *dest = Py_XNewRef(src); |
| 100 } | 126 } |
| 101 | 127 |
