Another fix to gdriver

This commit is contained in:
inmarket 2015-08-18 07:39:33 +10:00
parent 8a10ceb80b
commit 2867d6b8f9

View File

@ -52,13 +52,12 @@ GDriver *gdriverRegister(const GDriverVMT *vmt, void *param) {
return 0; return 0;
} }
// Add it to the driver chain // Add it to the driver chain (at the end)
if (dhead) { if (dhead)
dtail->driverchain = pd; dtail->driverchain = pd;
dtail = pd; else
} else { dhead = pd;
dhead = dtail = pd; dtail = pd;
}
// Do the post init // Do the post init
if (vmt->postinit) if (vmt->postinit)
@ -81,6 +80,8 @@ void gdriverUnRegister(GDriver *driver) {
for(pd = dhead; pd->driverchain; pd = pd->driverchain) { for(pd = dhead; pd->driverchain; pd = pd->driverchain) {
if (pd->driverchain == driver) { if (pd->driverchain == driver) {
pd->driverchain = driver->driverchain; pd->driverchain = driver->driverchain;
if (!pd->driverchain)
dtail = pd;
break; break;
} }
} }