Revision 7267c094 qga/guest-agent-commands.c

b/qga/guest-agent-commands.c
56 56

  
57 57
struct GuestAgentInfo *qmp_guest_info(Error **err)
58 58
{
59
    GuestAgentInfo *info = qemu_mallocz(sizeof(GuestAgentInfo));
59
    GuestAgentInfo *info = g_malloc0(sizeof(GuestAgentInfo));
60 60

  
61 61
    info->version = g_strdup(QGA_VERSION);
62 62

  
......
114 114
{
115 115
    GuestFileHandle *gfh;
116 116

  
117
    gfh = qemu_mallocz(sizeof(GuestFileHandle));
117
    gfh = g_malloc0(sizeof(GuestFileHandle));
118 118
    gfh->id = fileno(fh);
119 119
    gfh->fh = fh;
120 120
    QTAILQ_INSERT_TAIL(&guest_file_state.filehandles, gfh, next);
......
185 185
    }
186 186

  
187 187
    QTAILQ_REMOVE(&guest_file_state.filehandles, gfh, next);
188
    qemu_free(gfh);
188
    g_free(gfh);
189 189
}
190 190

  
191 191
struct GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count,
......
210 210
    }
211 211

  
212 212
    fh = gfh->fh;
213
    buf = qemu_mallocz(count+1);
213
    buf = g_malloc0(count+1);
214 214
    read_count = fread(buf, 1, count, fh);
215 215
    if (ferror(fh)) {
216 216
        slog("guest-file-read failed, handle: %ld", handle);
217 217
        error_set(err, QERR_QGA_COMMAND_FAILED, "fread() failed");
218 218
    } else {
219 219
        buf[read_count] = 0;
220
        read_data = qemu_mallocz(sizeof(GuestFileRead));
220
        read_data = g_malloc0(sizeof(GuestFileRead));
221 221
        read_data->count = read_count;
222 222
        read_data->eof = feof(fh);
223 223
        if (read_count) {
224 224
            read_data->buf_b64 = g_base64_encode(buf, read_count);
225 225
        }
226 226
    }
227
    qemu_free(buf);
227
    g_free(buf);
228 228
    clearerr(fh);
229 229

  
230 230
    return read_data;
......
251 251
    if (!has_count) {
252 252
        count = buf_len;
253 253
    } else if (count < 0 || count > buf_len) {
254
        qemu_free(buf);
254
        g_free(buf);
255 255
        error_set(err, QERR_INVALID_PARAMETER, "count");
256 256
        return NULL;
257 257
    }
......
261 261
        slog("guest-file-write failed, handle: %ld", handle);
262 262
        error_set(err, QERR_QGA_COMMAND_FAILED, "fwrite() error");
263 263
    } else {
264
        write_data = qemu_mallocz(sizeof(GuestFileWrite));
264
        write_data = g_malloc0(sizeof(GuestFileWrite));
265 265
        write_data->count = write_count;
266 266
        write_data->eof = feof(fh);
267 267
    }
268
    qemu_free(buf);
268
    g_free(buf);
269 269
    clearerr(fh);
270 270

  
271 271
    return write_data;
......
289 289
    if (ret == -1) {
290 290
        error_set(err, QERR_QGA_COMMAND_FAILED, strerror(errno));
291 291
    } else {
292
        seek_data = qemu_mallocz(sizeof(GuestFileRead));
292
        seek_data = g_malloc0(sizeof(GuestFileRead));
293 293
        seek_data->position = ftell(fh);
294 294
        seek_data->eof = feof(fh);
295 295
    }
......
355 355

  
356 356
    QTAILQ_FOREACH_SAFE(mount, &guest_fsfreeze_state.mount_list, next, temp) {
357 357
        QTAILQ_REMOVE(&guest_fsfreeze_state.mount_list, mount, next);
358
        qemu_free(mount->dirname);
359
        qemu_free(mount->devtype);
360
        qemu_free(mount);
358
        g_free(mount->dirname);
359
        g_free(mount->devtype);
360
        g_free(mount);
361 361
    }
362 362

  
363 363
    fp = setmntent(mtab, "r");
......
379 379
            continue;
380 380
        }
381 381

  
382
        mount = qemu_mallocz(sizeof(GuestFsfreezeMount));
383
        mount->dirname = qemu_strdup(ment->mnt_dir);
384
        mount->devtype = qemu_strdup(ment->mnt_type);
382
        mount = g_malloc0(sizeof(GuestFsfreezeMount));
383
        mount->dirname = g_strdup(ment->mnt_dir);
384
        mount->devtype = g_strdup(ment->mnt_type);
385 385

  
386 386
        QTAILQ_INSERT_TAIL(&guest_fsfreeze_state.mount_list, mount, next);
387 387
    }

Also available in: Unified diff