hw/eeprom93xx.c: substitute structure dump with discrete dump in eeprom_save/load
[qemu] / block-dmg.c
index 62117c9..82f6de1 100644 (file)
@@ -85,7 +85,7 @@ static int dmg_open(BlockDriverState *bs, const char *filename, int flags)
         return -errno;
     bs->read_only = 1;
     s->n_chunks = 0;
-    s->offsets = s->lengths = s->sectors = s->sectorcounts = 0;
+    s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL;
 
     /* read offset of info blocks */
     if(lseek(s->fd,-0x1d8,SEEK_END)<0) {
@@ -125,11 +125,11 @@ dmg_close:
                goto dmg_close;
            chunk_count = (count-204)/40;
            new_size = sizeof(uint64_t) * (s->n_chunks + chunk_count);
-           s->types = realloc(s->types, new_size/2);
-           s->offsets = realloc(s->offsets, new_size);
-           s->lengths = realloc(s->lengths, new_size);
-           s->sectors = realloc(s->sectors, new_size);
-           s->sectorcounts = realloc(s->sectorcounts, new_size);
+           s->types = qemu_realloc(s->types, new_size/2);
+           s->offsets = qemu_realloc(s->offsets, new_size);
+           s->lengths = qemu_realloc(s->lengths, new_size);
+           s->sectors = qemu_realloc(s->sectors, new_size);
+           s->sectorcounts = qemu_realloc(s->sectorcounts, new_size);
 
            for(i=s->n_chunks;i<s->n_chunks+chunk_count;i++) {
                s->types[i] = read_uint32(s->fd);
@@ -159,10 +159,8 @@ dmg_close:
     }
 
     /* initialize zlib engine */
-    if(!(s->compressed_chunk = malloc(max_compressed_size+1)))
-       goto dmg_close;
-    if(!(s->uncompressed_chunk = malloc(512*max_sectors_per_chunk)))
-       goto dmg_close;
+    s->compressed_chunk = qemu_malloc(max_compressed_size+1);
+    s->uncompressed_chunk = qemu_malloc(512*max_sectors_per_chunk);
     if(inflateInit(&s->zstream) != Z_OK)
        goto dmg_close;
 
@@ -286,12 +284,10 @@ static void dmg_close(BlockDriverState *bs)
 }
 
 BlockDriver bdrv_dmg = {
-    "dmg",
-    sizeof(BDRVDMGState),
-    dmg_probe,
-    dmg_open,
-    dmg_read,
-    NULL,
-    dmg_close,
+    .format_name       = "dmg",
+    .instance_size     = sizeof(BDRVDMGState),
+    .bdrv_probe                = dmg_probe,
+    .bdrv_open         = dmg_open,
+    .bdrv_read         = dmg_read,
+    .bdrv_close                = dmg_close,
 };
-