Revision 7267c094 savevm.c

b/savevm.c
206 206
static int socket_close(void *opaque)
207 207
{
208 208
    QEMUFileSocket *s = opaque;
209
    qemu_free(s);
209
    g_free(s);
210 210
    return 0;
211 211
}
212 212

  
......
234 234
    QEMUFileStdio *s = opaque;
235 235
    int ret;
236 236
    ret = pclose(s->stdio_file);
237
    qemu_free(s);
237
    g_free(s);
238 238
    return ret;
239 239
}
240 240

  
......
242 242
{
243 243
    QEMUFileStdio *s = opaque;
244 244
    fclose(s->stdio_file);
245
    qemu_free(s);
245
    g_free(s);
246 246
    return 0;
247 247
}
248 248

  
......
255 255
        return NULL;
256 256
    }
257 257

  
258
    s = qemu_mallocz(sizeof(QEMUFileStdio));
258
    s = g_malloc0(sizeof(QEMUFileStdio));
259 259

  
260 260
    s->stdio_file = stdio_file;
261 261

  
......
303 303
        return NULL;
304 304
    }
305 305

  
306
    s = qemu_mallocz(sizeof(QEMUFileStdio));
306
    s = g_malloc0(sizeof(QEMUFileStdio));
307 307
    s->stdio_file = fdopen(fd, mode);
308 308
    if (!s->stdio_file)
309 309
        goto fail;
......
318 318
    return s->file;
319 319

  
320 320
fail:
321
    qemu_free(s);
321
    g_free(s);
322 322
    return NULL;
323 323
}
324 324

  
325 325
QEMUFile *qemu_fopen_socket(int fd)
326 326
{
327
    QEMUFileSocket *s = qemu_mallocz(sizeof(QEMUFileSocket));
327
    QEMUFileSocket *s = g_malloc0(sizeof(QEMUFileSocket));
328 328

  
329 329
    s->fd = fd;
330 330
    s->file = qemu_fopen_ops(s, NULL, socket_get_buffer, socket_close, 
......
358 358
        return NULL;
359 359
    }
360 360

  
361
    s = qemu_mallocz(sizeof(QEMUFileStdio));
361
    s = g_malloc0(sizeof(QEMUFileStdio));
362 362

  
363 363
    s->stdio_file = fopen(filename, mode);
364 364
    if (!s->stdio_file)
......
373 373
    }
374 374
    return s->file;
375 375
fail:
376
    qemu_free(s);
376
    g_free(s);
377 377
    return NULL;
378 378
}
379 379

  
......
411 411
{
412 412
    QEMUFile *f;
413 413

  
414
    f = qemu_mallocz(sizeof(QEMUFile));
414
    f = g_malloc0(sizeof(QEMUFile));
415 415

  
416 416
    f->opaque = opaque;
417 417
    f->put_buffer = put_buffer;
......
477 477
    qemu_fflush(f);
478 478
    if (f->close)
479 479
        ret = f->close(f->opaque);
480
    qemu_free(f);
480
    g_free(f);
481 481
    return ret;
482 482
}
483 483

  
......
1114 1114
{
1115 1115
    SaveStateEntry *se;
1116 1116

  
1117
    se = qemu_mallocz(sizeof(SaveStateEntry));
1117
    se = g_malloc0(sizeof(SaveStateEntry));
1118 1118
    se->version_id = version_id;
1119 1119
    se->section_id = global_section_id++;
1120 1120
    se->set_params = set_params;
......
1130 1130
        if (id) {
1131 1131
            pstrcpy(se->idstr, sizeof(se->idstr), id);
1132 1132
            pstrcat(se->idstr, sizeof(se->idstr), "/");
1133
            qemu_free(id);
1133
            g_free(id);
1134 1134

  
1135
            se->compat = qemu_mallocz(sizeof(CompatEntry));
1135
            se->compat = g_malloc0(sizeof(CompatEntry));
1136 1136
            pstrcpy(se->compat->idstr, sizeof(se->compat->idstr), idstr);
1137 1137
            se->compat->instance_id = instance_id == -1 ?
1138 1138
                         calculate_compat_instance_id(idstr) : instance_id;
......
1174 1174
        if (path) {
1175 1175
            pstrcpy(id, sizeof(id), path);
1176 1176
            pstrcat(id, sizeof(id), "/");
1177
            qemu_free(path);
1177
            g_free(path);
1178 1178
        }
1179 1179
    }
1180 1180
    pstrcat(id, sizeof(id), idstr);
......
1183 1183
        if (strcmp(se->idstr, id) == 0 && se->opaque == opaque) {
1184 1184
            QTAILQ_REMOVE(&savevm_handlers, se, entry);
1185 1185
            if (se->compat) {
1186
                qemu_free(se->compat);
1186
                g_free(se->compat);
1187 1187
            }
1188
            qemu_free(se);
1188
            g_free(se);
1189 1189
        }
1190 1190
    }
1191 1191
}
......
1203 1203
        if (path) {
1204 1204
            pstrcpy(id, sizeof(id), path);
1205 1205
            pstrcat(id, sizeof(id), "/");
1206
            qemu_free(path);
1206
            g_free(path);
1207 1207
        }
1208 1208
    }
1209 1209
    pstrcat(id, sizeof(id), idstr);
......
1225 1225
    /* If this triggers, alias support can be dropped for the vmsd. */
1226 1226
    assert(alias_id == -1 || required_for_version >= vmsd->minimum_version_id);
1227 1227

  
1228
    se = qemu_mallocz(sizeof(SaveStateEntry));
1228
    se = g_malloc0(sizeof(SaveStateEntry));
1229 1229
    se->version_id = vmsd->version_id;
1230 1230
    se->section_id = global_section_id++;
1231 1231
    se->save_live_state = NULL;
......
1241 1241
        if (id) {
1242 1242
            pstrcpy(se->idstr, sizeof(se->idstr), id);
1243 1243
            pstrcat(se->idstr, sizeof(se->idstr), "/");
1244
            qemu_free(id);
1244
            g_free(id);
1245 1245

  
1246
            se->compat = qemu_mallocz(sizeof(CompatEntry));
1246
            se->compat = g_malloc0(sizeof(CompatEntry));
1247 1247
            pstrcpy(se->compat->idstr, sizeof(se->compat->idstr), vmsd->name);
1248 1248
            se->compat->instance_id = instance_id == -1 ?
1249 1249
                         calculate_compat_instance_id(vmsd->name) : instance_id;
......
1279 1279
        if (se->vmsd == vmsd && se->opaque == opaque) {
1280 1280
            QTAILQ_REMOVE(&savevm_handlers, se, entry);
1281 1281
            if (se->compat) {
1282
                qemu_free(se->compat);
1282
                g_free(se->compat);
1283 1283
            }
1284
            qemu_free(se);
1284
            g_free(se);
1285 1285
        }
1286 1286
    }
1287 1287
}
......
1785 1785
            }
1786 1786

  
1787 1787
            /* Add entry */
1788
            le = qemu_mallocz(sizeof(*le));
1788
            le = g_malloc0(sizeof(*le));
1789 1789

  
1790 1790
            le->se = se;
1791 1791
            le->section_id = section_id;
......
1835 1835
out:
1836 1836
    QLIST_FOREACH_SAFE(le, &loadvm_handlers, entry, new_le) {
1837 1837
        QLIST_REMOVE(le, entry);
1838
        qemu_free(le);
1838
        g_free(le);
1839 1839
    }
1840 1840

  
1841 1841
    if (qemu_file_has_error(f))
......
1862 1862
            break;
1863 1863
        }
1864 1864
    }
1865
    qemu_free(sn_tab);
1865
    g_free(sn_tab);
1866 1866
    return ret;
1867 1867
}
1868 1868

  
......
2141 2141
        return;
2142 2142
    }
2143 2143

  
2144
    available_snapshots = qemu_mallocz(sizeof(int) * nb_sns);
2144
    available_snapshots = g_malloc0(sizeof(int) * nb_sns);
2145 2145
    total = 0;
2146 2146
    for (i = 0; i < nb_sns; i++) {
2147 2147
        sn = &sn_tab[i];
......
2174 2174
        monitor_printf(mon, "There is no suitable snapshot available\n");
2175 2175
    }
2176 2176

  
2177
    qemu_free(sn_tab);
2178
    qemu_free(available_snapshots);
2177
    g_free(sn_tab);
2178
    g_free(available_snapshots);
2179 2179

  
2180 2180
}

Also available in: Unified diff