diff options
Diffstat (limited to 'Demo/embed/loop.c')
-rw-r--r-- | Demo/embed/loop.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Demo/embed/loop.c b/Demo/embed/loop.c new file mode 100644 index 0000000..ca89cb7 --- /dev/null +++ b/Demo/embed/loop.c @@ -0,0 +1,26 @@ +/* Simple program that repeatedly calls Py_Initialize(), does something, and + then calls Py_Finalize(). This should help finding leaks related to + initialization. */ + +#include "Python.h" + +main(int argc, char **argv) +{ + char *command; + + if (argc != 2) { + fprintf(stderr, "usage: loop <python-command>\n"); + exit(2); + } + + command = argv[1]; + + Py_SetProgramName(argv[0]); + + while (1) { + Py_Initialize(); + PyRun_SimpleString(command); + Py_Finalize(); + } + /*NOTREACHED*/ +} |