Fix refcounting.

This makes 'import ctypes; reload(ctypes)' no longer leak reference counts.
This commit is contained in:
Thomas Heller 2006-04-18 14:57:39 +00:00
parent a4ebc135ac
commit 9d89299fea
1 changed files with 2 additions and 0 deletions

View File

@ -1283,6 +1283,7 @@ static PyObject *CreateSwappedType(PyTypeObject *type, PyObject *args, PyObject
suffix = PyString_FromString("_be"); suffix = PyString_FromString("_be");
#endif #endif
Py_INCREF(name);
PyString_Concat(&name, suffix); PyString_Concat(&name, suffix);
if (name == NULL) if (name == NULL)
return NULL; return NULL;
@ -1459,6 +1460,7 @@ SimpleType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject_SetAttrString(swapped, "__ctype_le__", (PyObject *)result); PyObject_SetAttrString(swapped, "__ctype_le__", (PyObject *)result);
PyObject_SetAttrString(swapped, "__ctype_be__", swapped); PyObject_SetAttrString(swapped, "__ctype_be__", swapped);
#endif #endif
Py_DECREF(swapped);
}; };
return (PyObject *)result; return (PyObject *)result;