/* First, search Drivers list to see if we've already opened this driver */
for (driver = Drivers; driver; driver = driver->next) {
if (strcmp(driver->name, driverName) == 0) {
- /* found it */
+ /* found it, increment library refcount & return */
+ dlopen(driver->libpath, RTLD_NOW | RTLD_GLOBAL);
return driver;
}
}
break; /* out of memory! */
/* init the struct */
driver->name = __glXstrdup(driverName);
- if (!driver->name) {
+ driver->libpath = __glXstrdup(realDriverName);
+ if (!driver->name || !driver->libpath) {
+ if (driver->name) XFree(driver->name);
Xfree(driver);
driver = NULL;
break; /* out of memory! */
Drivers = driver->next;
Xfree(driver->name);
+ Xfree(driver->libpath);
Xfree(driver);
break;
}