Reset the freed device name list so it is not freed a second time on republish. Also check the allocation of the new name list.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23337 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2008-01-10 11:45:20 +00:00
parent dd7579a79b
commit 86fee1806c
@@ -611,6 +611,7 @@ uninit_driver()
for (int32 i = 1; gDeviceNames[i]; i++)
free(gDeviceNames[i]);
free(gDeviceNames);
gDeviceNames = NULL;
}
benaphore_destroy(&gDeviceListLock);
@@ -626,10 +627,14 @@ publish_devices()
for (int32 i = 1; gDeviceNames[i]; i++)
free(gDeviceNames[i]);
free(gDeviceNames);
gDeviceNames = NULL;
}
int32 index = 0;
gDeviceNames = (char **)malloc(sizeof(char *) * (gDeviceCount + 2));
if (!gDeviceNames)
return NULL;
gDeviceNames[index++] = DEVICE_NAME;
benaphore_lock(&gDeviceListLock);