Beispiel #1
0
void *
_glthread_GetTSD(_glthread_TSD *tsd)
{
   void *ptr;
   if (tsd->initMagic != INIT_MAGIC) {
      _glthread_InitTSD(tsd);
   }
   xthread_get_specific(tsd->key, &ptr);
   return ptr;
}
static glitz_glx_thread_info_t *
_glitz_glx_thread_info_get (const char *gl_library)
{
    glitz_glx_thread_info_t *thread_info;
    void *p;

    if (!tsd_initialized) {
	xthread_key_create (&info_tsd, _tsd_destroy);
	tsd_initialized = 1;
    }

    xthread_get_specific (info_tsd, &p);

    if (p == NULL) {
	thread_info = malloc (sizeof (glitz_glx_thread_info_t));
	_glitz_glx_thread_info_init (thread_info);

	xthread_set_specific (info_tsd, thread_info);
    } else
	thread_info = (glitz_glx_thread_info_t *) p;

    if (gl_library) {
	int len = strlen (gl_library);

	if (thread_info->gl_library) {
	    free (thread_info->gl_library);
	    thread_info->gl_library = NULL;
	}

	thread_info->gl_library = malloc (len + 1);
	if (thread_info->gl_library) {
	    memcpy (thread_info->gl_library, gl_library, len);
	    thread_info->gl_library[len] = '\0';
	}
    }

    return thread_info;
}