--- trunk/src/disk/bootblock.c 2007/10/08 16:22:20 41 +++ trunk/src/disk/bootblock.c 2007/10/08 16:22:32 42 @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: bootblock.c,v 1.1 2007/03/16 14:45:30 debug Exp $ + * $Id: bootblock.c,v 1.4 2007/06/15 17:02:39 debug Exp $ * * Bootblock handling: * @@ -49,7 +49,7 @@ #include "diskimage.h" #include "emul.h" #include "machine.h" -#include "misc.h" +#include "memory.h" static char *diskimage_types[] = DISKIMAGE_TYPES; @@ -90,11 +90,7 @@ exit(1); } - bootblock_buf = malloc(32768); - if (bootblock_buf == NULL) { - fprintf(stderr, "Out of memory.\n"); - exit(1); - } + CHECK_ALLOCATION(bootblock_buf = malloc(32768)); debug("loading Dreamcast IP.BIN from %s id %i\n", diskimage_types[boot_disk_type], boot_disk_id); @@ -125,8 +121,8 @@ bootblock_buf[i] = 0; i ++; } - cpu->machine->boot_kernel_filename = strdup( - (char *)bootblock_buf + 0x60); + CHECK_ALLOCATION(cpu->machine->boot_kernel_filename = + strdup((char *)bootblock_buf + 0x60)); } debug("boot filename: %s\n", @@ -183,8 +179,8 @@ bootblock_pc |= 0xffffffffa0000000ULL; cpu->pc = bootblock_pc; - debug("DEC boot: loadaddr=0x%08x, pc=0x%08x", - (int)bootblock_loadaddr, (int)bootblock_pc); + debug("DEC boot: loadaddr=0x%08"PRIx32", pc=0x%08"PRIx32, + (uint32_t) bootblock_loadaddr, (uint32_t) bootblock_pc); readofs = 0x18; @@ -212,12 +208,7 @@ fatal("\nWARNING! Unusually large bootblock " "(%i bytes)\n\n", n_blocks * 512); - bootblock_buf = malloc(n_blocks * 512); - if (bootblock_buf == NULL) { - fprintf(stderr, "out of memory in " - "load_bootblock()\n"); - exit(1); - } + CHECK_ALLOCATION(bootblock_buf = malloc(n_blocks*512)); res = diskimage_access(m, boot_disk_id, boot_disk_type, 0, bootblock_offset, bootblock_buf, n_blocks * 512); @@ -245,12 +236,7 @@ * does not rely on machine-dependent boot blocks etc. */ /* ISO9660: (0x800 bytes at 0x8000 + base_offset) */ - bootblock_buf = malloc(0x800); - if (bootblock_buf == NULL) { - fprintf(stderr, "Out of memory.\n"); - exit(1); - } - + CHECK_ALLOCATION(bootblock_buf = malloc(0x800)); res = diskimage_access(m, boot_disk_id, boot_disk_type, 0, base_offset + 0x8000, bootblock_buf, 0x800); if (!res) {