static int _init_profiler(void) { // already initialized? only after clear_stats() and first time, this flag // will be unset. if (!yappinitialized) { contexts = htcreate(HT_CTX_SIZE); if (!contexts) goto error; flpit = flcreate(sizeof(_pit), FL_PIT_SIZE); if (!flpit) goto error; flctx = flcreate(sizeof(_ctx), FL_CTX_SIZE); if (!flctx) goto error; yappinitialized = 1; } return 1; error: if (contexts) { htdestroy(contexts); contexts = NULL; } if (flpit) { fldestroy(flpit); flpit = NULL; } if (flctx) { fldestroy(flctx); flctx = NULL; } return 0; }
static PyObject* clear_stats(PyObject *self, PyObject *args) { PyObject *d; if (!yapphavestats) { Py_RETURN_NONE; } current_ctx = NULL; prev_ctx = NULL; initial_ctx = NULL; henum(contexts, _ctxenumdel, NULL); htdestroy(contexts); contexts = NULL; fldestroy(flpit); flpit = NULL; fldestroy(flctx); flctx = NULL; yappinitialized = 0; yapphavestats = 0; ycurfuncindex = 0; ycurthreadindex = 0; d = PyThreadState_GET()->dict; if (PyDict_GetItemString(d, "_yappi_tid")) { PyDict_DelItemString(d, "_yappi_tid"); } Py_CLEAR(test_timings); // check for mem leaks if DEBUG_MEM is specified #ifdef DEBUG_MEM YMEMLEAKCHECK(); #endif Py_RETURN_NONE; }
/* * This thread keeps track of the playback status and closes the file and * audio device if the track ends or on a abort signal. It than resets all * playback related variables. */ static void * watchthread(void *arg) { while (!abortflag && !eofflag) SDL_Delay(100); pthread_join(decodetid, NULL); SDL_CloseAudio(); closefile(); fldestroy(); /* reset playack related variables */ abortflag = 0; eofflag = 0; duration = 0; position = 0; abuf = NULL; abuflen = 0; abufi = 0; state = STOPPED; pthread_exit(NULL); }