BUGFIX memory leak
BUGFIX memory leak

Since pthread_once() is called only once in a process, also the destructor
in pthread_key_create() is the same for all threads. But we use dynamic
memory for threads and static memory for the main thread. Therefore, we
have to check in destructor (and we cannot use standard free()) for freeing
static memory if someone will use pthread_exit() in main().

Fixes #15

lukasmacko/libyang,PavolVican/libyang,PavolVican/libyang,lukasmacko/libyang,PavolVican/libyang,PavolVican/libyang,PavolVican/libyang