summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-03-02 19:48:06 (GMT)
committerFred Drake <fdrake@acm.org>2001-03-02 19:48:06 (GMT)
commit80d4c0777548a4527b5b719c23256779c6acc637 (patch)
tree31ed949e6f6523794c48ba9a232af625ccbd3f33 /Doc
parentab357ecf7f5b65374eb967281a84965f05e5179c (diff)
downloadcpython-80d4c0777548a4527b5b719c23256779c6acc637.zip
cpython-80d4c0777548a4527b5b719c23256779c6acc637.tar.gz
cpython-80d4c0777548a4527b5b719c23256779c6acc637.tar.bz2
There was a real leak in the "export a C API" example; fix that one.
(There are too many initspam() functions; they need to be renamed post-beta.)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/ext/ext.tex13
1 files changed, 9 insertions, 4 deletions
diff --git a/Doc/ext/ext.tex b/Doc/ext/ext.tex
index 4cd4af0..250859b 100644
--- a/Doc/ext/ext.tex
+++ b/Doc/ext/ext.tex
@@ -1619,9 +1619,10 @@ the C API pointer array:
void
initspam()
{
- PyObject *m, *d;
+ PyObject *m;
static void *PySpam_API[PySpam_API_pointers];
PyObject *c_api_object;
+
m = Py_InitModule("spam", SpamMethods);
/* Initialize the C API pointer array */
@@ -1630,9 +1631,13 @@ initspam()
/* Create a CObject containing the API pointer array's address */
c_api_object = PyCObject_FromVoidPtr((void *)PySpam_API, NULL);
- /* Create a name for this object in the module's namespace */
- d = PyModule_GetDict(m);
- PyDict_SetItemString(d, "_C_API", c_api_object);
+ if (c_api_object != NULL) {
+ /* Create a name for this object in the module's namespace */
+ PyObject *d = PyModule_GetDict(m);
+
+ PyDict_SetItemString(d, "_C_API", c_api_object);
+ Py_DECREF(c_api_object);
+ }
}
\end{verbatim}