Decref global error on thread exit
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/57b57df5 Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/57b57df5 Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/57b57df5 Branch: refs/heads/thread_safe_errors Commit: 57b57df51ba93f2e81199f2f8848cecb0afa6b79 Parents: 46eb715 Author: Nick Wellnhofer <[email protected]> Authored: Wed Dec 24 18:07:36 2014 +0100 Committer: Nick Wellnhofer <[email protected]> Committed: Wed Dec 24 18:07:36 2014 +0100 ---------------------------------------------------------------------- runtime/c/src/Clownfish/Err.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/57b57df5/runtime/c/src/Clownfish/Err.c ---------------------------------------------------------------------- diff --git a/runtime/c/src/Clownfish/Err.c b/runtime/c/src/Clownfish/Err.c index 69b9b79..ec588db 100644 --- a/runtime/c/src/Clownfish/Err.c +++ b/runtime/c/src/Clownfish/Err.c @@ -83,8 +83,13 @@ S_get_globals() { BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, LPVOID reserved) { if (reason == DLL_THREAD_DETACH) { - void *globals = TlsGetValue(err_globals_tls_index); - FREEMEM(globals); + cfish_ErrGlobals *globals + = (cfish_ErrGlobals*)TlsGetValue(err_globals_tls_index); + + if (globals) { + DECREF(globals->current_error); + FREEMEM(globals); + } } return TRUE; @@ -127,7 +132,9 @@ S_get_globals() { } static void -S_destroy_globals(void *globals) { +S_destroy_globals(void *arg) { + cfish_ErrGlobals *globals = (cfish_ErrGlobals*)arg; + DECREF(globals->current_error); FREEMEM(globals); }
