Duplicate device on open and free on close, close device on map close

This commit is contained in:
Laurent Vivier 2007-10-10 20:49:55 +00:00
parent 2e5094aff9
commit e134c95553
2 changed files with 9 additions and 1 deletions

View File

@ -11,5 +11,7 @@
void map_close(map_t *map)
{
map->device->close(map->device);
free(map->device);
free(map);
}

View File

@ -28,7 +28,13 @@ map_t* map_open(device_io_t *device)
if (map == NULL)
return NULL;
map->device = device;
map->device = malloc(sizeof(device_io_t));
if (map->device == NULL)
{
free(map);
return NULL;
}
memcpy(map->device, device, sizeof(device_io_t));
ret = device->read_sector(map->device->data, 0,
&map->drivers, sizeof(map->drivers));