src/GLX/libglxmapping.c
static __GLXdisplayInfoHash *InitDisplayInfoEntry(Display *dpy)
{
    __GLXdisplayInfoHash *pEntry;
    size_t size;
    int eventBase;

    size = sizeof(*pEntry) + ScreenCount(dpy) * sizeof(__GLXvendorInfo *);
    pEntry = (__GLXdisplayInfoHash *) malloc(size);
    if (pEntry == NULL) {
        return NULL;
    }

    memset(pEntry, 0, size);
    pEntry->info.dpy = dpy;
    pEntry->info.vendors = (__GLXvendorInfo **) (pEntry + 1);

    LKDHASH_INIT(pEntry->info.xidVendorHash);
    __glvndPthreadFuncs.rwlock_init(&pEntry->info.vendorLock, NULL);

    // Check whether the server supports the GLX extension, and record the
    // major opcode if it does.
    pEntry->info.glxSupported = XQueryExtension(dpy, GLX_EXTENSION_NAME,
            &pEntry->info.glxMajorOpcode, &eventBase,
            &pEntry->info.glxFirstError);

    if (pEntry->info.glxSupported) {
        int screen;

        // Check to see if the server supports the GLX_EXT_libglvnd extension.
        // Note that it has to be supported on every screen to use it.
        pEntry->info.libglvndExtensionSupported = True;
        for (screen = 0;
                screen < ScreenCount(dpy) && pEntry->info.libglvndExtensionSupported;
                screen++) {
            char *extensions = __glXQueryServerString(&pEntry->info, screen, GLX_EXTENSIONS);
            if (extensions != NULL) {
                if (!IsExtensionInString(extensions, GLX_EXT_LIBGLVND_NAME,
                            strlen(GLX_EXT_LIBGLVND_NAME))) {
                    pEntry->info.libglvndExtensionSupported = False;
                }
                free(extensions);
            } else {
                pEntry->info.libglvndExtensionSupported = False;
            }
        }
    }

    return pEntry;
}
/**
 * Allocates and initializes a __GLXdisplayInfoHash structure.
 *
 * The caller is responsible for adding the structure to the hashtable.
 *
 * \param dpy The display connection.
 * \return A newly-allocated __GLXdisplayInfoHash structure, or NULL on error.
 */
Allocates and initializes a __GLXdisplayInfoHash structure.
The caller is responsible for adding the structure to the hashtable.

\param dpy The display connection.
\return A newly-allocated __GLXdisplayInfoHash structure, or NULL on error.
Allocates and initializes a __GLXdisplayInfoHash structure . The caller is responsible for adding the structure to the hashtable . \ param dpy The display connection . \ return A newly - allocated __GLXdisplayInfoHash structure or NULL on error .
static __GLXdisplayInfoHash *InitDisplayInfoEntry(Display *dpy)
{
    __GLXdisplayInfoHash *pEntry;
    size_t size;
    int eventBase;
    size = sizeof(*pEntry) + ScreenCount(dpy) * sizeof(__GLXvendorInfo *);
    pEntry = (__GLXdisplayInfoHash *) malloc(size);
    if (pEntry == NULL) {
        return NULL;
    }
    memset(pEntry, 0, size);
    pEntry->info.dpy = dpy;
    pEntry->info.vendors = (__GLXvendorInfo **) (pEntry + 1);
    LKDHASH_INIT(pEntry->info.xidVendorHash);
    __glvndPthreadFuncs.rwlock_init(&pEntry->info.vendorLock, NULL);
    pEntry->info.glxSupported = XQueryExtension(dpy, GLX_EXTENSION_NAME,
            &pEntry->info.glxMajorOpcode, &eventBase,
            &pEntry->info.glxFirstError);
    if (pEntry->info.glxSupported) {
        int screen;
        pEntry->info.libglvndExtensionSupported = True;
        for (screen = 0;
                screen < ScreenCount(dpy) && pEntry->info.libglvndExtensionSupported;
                screen++) {
            char *extensions = __glXQueryServerString(&pEntry->info, screen, GLX_EXTENSIONS);
            if (extensions != NULL) {
                if (!IsExtensionInString(extensions, GLX_EXT_LIBGLVND_NAME,
                            strlen(GLX_EXT_LIBGLVND_NAME))) {
                    pEntry->info.libglvndExtensionSupported = False;
                }
                free(extensions);
            } else {
                pEntry->info.libglvndExtensionSupported = False;
            }
        }
    }
    return pEntry;
}
static __GLXdisplayInfoHash * InitDisplayInfoEntry ( Display * dpy ) { __GLXdisplayInfoHash * pEntry ; size_t size ; int eventBase ; size = sizeof ( * pEntry ) + ScreenCount ( dpy ) * sizeof ( __GLXvendorInfo * ) ; pEntry = ( __GLXdisplayInfoHash * ) malloc ( size ) ; if ( pEntry == NULL ) { return NULL ; } memset ( pEntry , 0 , size ) ; pEntry -> info . dpy = dpy ; pEntry -> info . vendors = ( __GLXvendorInfo * * ) ( pEntry + 1 ) ; LKDHASH_INIT ( pEntry -> info . xidVendorHash ) ; __glvndPthreadFuncs . rwlock_init ( & pEntry -> info . vendorLock , NULL ) ; pEntry -> info . glxSupported = XQueryExtension ( dpy , GLX_EXTENSION_NAME , & pEntry -> info . glxMajorOpcode , & eventBase , & pEntry -> info . glxFirstError ) ; if ( pEntry -> info . glxSupported ) { int screen ; pEntry -> info . libglvndExtensionSupported = True ; for ( screen = 0 ; screen < ScreenCount ( dpy ) && pEntry -> info . libglvndExtensionSupported ; screen ++ ) { char * extensions = __glXQueryServerString ( & pEntry -> info , screen , GLX_EXTENSIONS ) ; if ( extensions != NULL ) { if ( ! IsExtensionInString ( extensions , GLX_EXT_LIBGLVND_NAME , strlen ( GLX_EXT_LIBGLVND_NAME ) ) ) { pEntry -> info . libglvndExtensionSupported = False ; } free ( extensions ) ; } else { pEntry -> info . libglvndExtensionSupported = False ; } } } return pEntry ; }
Allocates and initializes a __GLXdisplayInfoHash structure.
Allocates and initializes a __GLXdisplayInfoHash structure .
// Check whether the server supports the GLX extension, and record the // major opcode if it does. // Check to see if the server supports the GLX_EXT_libglvnd extension. // Note that it has to be supported on every screen to use it.