- int driveid = Drives.drivecount;
- if (driveid >= ARRAY_SIZE(Drives.drives))
- return -1;
- Drives.drivecount++;
- memset(&Drives.drives[driveid], 0, sizeof(Drives.drives[0]));
- Drives.drives[driveid].cntl_id = floppyid;
- Drives.drives[driveid].type = driver;
- Drives.drives[driveid].blksize = FLOPPY_SECTOR_SIZE;
- Drives.drives[driveid].floppy_type = ftype;
- Drives.drives[driveid].sectors = (u16)-1;
-
- memcpy(&Drives.drives[driveid].lchs, &FloppyInfo[ftype].chs
+ struct drive_s *drive_g = malloc_fseg(sizeof(*drive_g));
+ if (!drive_g) {
+ warn_noalloc();
+ return NULL;
+ }
+ memset(drive_g, 0, sizeof(*drive_g));
+ drive_g->cntl_id = floppyid;
+ drive_g->type = DTYPE_FLOPPY;
+ drive_g->blksize = DISK_SECTOR_SIZE;
+ drive_g->floppy_type = ftype;
+ drive_g->sectors = (u64)-1;
+
+ memcpy(&drive_g->lchs, &FloppyInfo[ftype].chs