Commit b6d79cd5 authored by Guido van Rossum's avatar Guido van Rossum

added Py_AtExit() -- register cleanup functions for C modules

parent 60529a19
......@@ -466,6 +466,19 @@ fatal(msg)
int threads_started = 0; /* Set by threadmodule.c and maybe others */
#endif
#define NEXITFUNCS 32
static void (*exitfuncs[NEXITFUNCS])();
static int nexitfuncs = 0;
int Py_AtExit(func)
void (*func) PROTO((void));
{
if (nexitfuncs >= NEXITFUNCS)
return -1;
exitfuncs[nexitfuncs++] = func;
return 0;
}
void
cleanup()
{
......@@ -489,6 +502,9 @@ cleanup()
}
flushline();
while (nexitfuncs > 0)
(*exitfuncs[--nexitfuncs])();
}
#ifdef COUNT_ALLOCS
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment