2001-01-11 01:11:51 +08:00
|
|
|
/* 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)
|
|
|
|
{
|
2001-01-24 00:42:01 +08:00
|
|
|
int count = -1;
|
2001-01-11 01:11:51 +08:00
|
|
|
char *command;
|
|
|
|
|
2001-01-24 00:42:01 +08:00
|
|
|
if (argc < 2 || argc > 3) {
|
|
|
|
fprintf(stderr, "usage: loop <python-command> [count]\n");
|
2001-01-11 01:11:51 +08:00
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
command = argv[1];
|
|
|
|
|
2001-01-24 00:42:01 +08:00
|
|
|
if (argc == 3) {
|
|
|
|
count = atoi(argv[2]);
|
|
|
|
}
|
|
|
|
|
2001-01-11 01:11:51 +08:00
|
|
|
Py_SetProgramName(argv[0]);
|
|
|
|
|
2001-01-24 00:42:01 +08:00
|
|
|
/* uncomment this if you don't want to load site.py */
|
|
|
|
/* Py_NoSiteFlag = 1; */
|
|
|
|
|
|
|
|
while (count == -1 || --count >= 0 ) {
|
2001-01-11 01:11:51 +08:00
|
|
|
Py_Initialize();
|
|
|
|
PyRun_SimpleString(command);
|
|
|
|
Py_Finalize();
|
|
|
|
}
|
2001-01-24 00:42:01 +08:00
|
|
|
return 0;
|
2001-01-11 01:11:51 +08:00
|
|
|
}
|