File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818#define PyInt_FromLong (value ) PyLong_FromLong(value)
1919#endif
2020
21+ /* Reference stealing version of PyDict_SetItemString */
22+ static void set_dict_item_steal (PyObject * dict , const char * name , PyObject * py_value )
23+ {
24+ PyDict_SetItemString (dict , name , py_value );
25+ Py_DECREF (py_value );
26+ }
27+
2128/* Helper for function below. */
2229#define ADD_ENUM (dict , name ) \
23- PyDict_SetItemString (dict, #name, PyInt_FromLong(name))
30+ set_dict_item_steal (dict, #name, PyInt_FromLong(name))
2431
2532/* Alas, EPICS has changed the numerical assignments of the DBF_ enums between
2633 * versions, so to avoid unpleasant surprises, we compute thes values here in C
@@ -76,7 +83,7 @@ static PyObject *get_field_offsets(PyObject *self, PyObject *args)
7683 dbentry .pflddes -> offset ,
7784 dbentry .pflddes -> size ,
7885 dbentry .pflddes -> field_type );
79- PyDict_SetItemString (dict , field_name , ost );
86+ set_dict_item_steal (dict , field_name , ost );
8087 status = dbNextField (& dbentry , 0 );
8188 }
8289
You can’t perform that action at this time.
0 commit comments