Revision 7267c094 ui/vnc.c

b/ui/vnc.c
67 67
    /* Enough for the existing format + the 2 vars we're
68 68
     * substituting in. */
69 69
    addrlen = strlen(format) + strlen(host) + strlen(serv);
70
    addr = qemu_malloc(addrlen + 1);
70
    addr = g_malloc(addrlen + 1);
71 71
    snprintf(addr, addrlen, format, host, serv);
72 72
    addr[addrlen] = '\0';
73 73

  
......
411 411
{
412 412
    if ((buffer->capacity - buffer->offset) < len) {
413 413
        buffer->capacity += (len + 1024);
414
        buffer->buffer = qemu_realloc(buffer->buffer, buffer->capacity);
414
        buffer->buffer = g_realloc(buffer->buffer, buffer->capacity);
415 415
        if (buffer->buffer == NULL) {
416 416
            fprintf(stderr, "vnc: out of memory\n");
417 417
            exit(1);
......
436 436

  
437 437
void buffer_free(Buffer *buffer)
438 438
{
439
    qemu_free(buffer->buffer);
439
    g_free(buffer->buffer);
440 440
    buffer->offset = 0;
441 441
    buffer->capacity = 0;
442 442
    buffer->buffer = NULL;
......
505 505

  
506 506
    /* server surface */
507 507
    if (!vd->server)
508
        vd->server = qemu_mallocz(sizeof(*vd->server));
508
        vd->server = g_malloc0(sizeof(*vd->server));
509 509
    if (vd->server->data)
510
        qemu_free(vd->server->data);
510
        g_free(vd->server->data);
511 511
    *(vd->server) = *(ds->surface);
512
    vd->server->data = qemu_mallocz(vd->server->linesize *
512
    vd->server->data = g_malloc0(vd->server->linesize *
513 513
                                    vd->server->height);
514 514

  
515 515
    /* guest surface */
516 516
    if (!vd->guest.ds)
517
        vd->guest.ds = qemu_mallocz(sizeof(*vd->guest.ds));
517
        vd->guest.ds = g_malloc0(sizeof(*vd->guest.ds));
518 518
    if (ds_get_bytes_per_pixel(ds) != vd->guest.ds->pf.bytes_per_pixel)
519 519
        console_color_init(ds);
520 520
    *(vd->guest.ds) = *(ds->surface);
......
781 781
    VncState *vs;
782 782

  
783 783
    cursor_put(vd->cursor);
784
    qemu_free(vd->cursor_mask);
784
    g_free(vd->cursor_mask);
785 785

  
786 786
    vd->cursor = c;
787 787
    cursor_get(vd->cursor);
788 788
    vd->cursor_msize = cursor_get_mono_bpl(c) * c->height;
789
    vd->cursor_mask = qemu_mallocz(vd->cursor_msize);
789
    vd->cursor_mask = g_malloc0(vd->cursor_msize);
790 790
    cursor_get_mono_mask(c, 0, vd->cursor_mask);
791 791

  
792 792
    QTAILQ_FOREACH(vs, &vd->clients, next) {
......
1013 1013
    qemu_mutex_destroy(&vs->output_mutex);
1014 1014
#endif
1015 1015
    for (i = 0; i < VNC_STAT_ROWS; ++i) {
1016
        qemu_free(vs->lossy_rect[i]);
1016
        g_free(vs->lossy_rect[i]);
1017 1017
    }
1018
    qemu_free(vs->lossy_rect);
1019
    qemu_free(vs);
1018
    g_free(vs->lossy_rect);
1019
    g_free(vs);
1020 1020
}
1021 1021

  
1022 1022
int vnc_client_io_error(VncState *vs, int ret, int last_errno)
......
2496 2496

  
2497 2497
static void vnc_connect(VncDisplay *vd, int csock, int skipauth)
2498 2498
{
2499
    VncState *vs = qemu_mallocz(sizeof(VncState));
2499
    VncState *vs = g_malloc0(sizeof(VncState));
2500 2500
    int i;
2501 2501

  
2502 2502
    vs->csock = csock;
......
2513 2513
#endif
2514 2514
    }
2515 2515

  
2516
    vs->lossy_rect = qemu_mallocz(VNC_STAT_ROWS * sizeof (*vs->lossy_rect));
2516
    vs->lossy_rect = g_malloc0(VNC_STAT_ROWS * sizeof (*vs->lossy_rect));
2517 2517
    for (i = 0; i < VNC_STAT_ROWS; ++i) {
2518
        vs->lossy_rect[i] = qemu_mallocz(VNC_STAT_COLS * sizeof (uint8_t));
2518
        vs->lossy_rect[i] = g_malloc0(VNC_STAT_COLS * sizeof (uint8_t));
2519 2519
    }
2520 2520

  
2521 2521
    VNC_DEBUG("New client on socket %d\n", csock);
......
2576 2576

  
2577 2577
void vnc_display_init(DisplayState *ds)
2578 2578
{
2579
    VncDisplay *vs = qemu_mallocz(sizeof(*vs));
2579
    VncDisplay *vs = g_malloc0(sizeof(*vs));
2580 2580

  
2581
    dcl = qemu_mallocz(sizeof(DisplayChangeListener));
2581
    dcl = g_malloc0(sizeof(DisplayChangeListener));
2582 2582

  
2583 2583
    ds->opaque = vs;
2584 2584
    dcl->idle = 1;
......
2620 2620
    if (!vs)
2621 2621
        return;
2622 2622
    if (vs->display) {
2623
        qemu_free(vs->display);
2623
        g_free(vs->display);
2624 2624
        vs->display = NULL;
2625 2625
    }
2626 2626
    if (vs->lsock != -1) {
......
2644 2644
    }
2645 2645

  
2646 2646
    if (vs->password) {
2647
        qemu_free(vs->password);
2647
        g_free(vs->password);
2648 2648
    }
2649 2649

  
2650 2650
    vs->password = NULL;
......
2671 2671
    }
2672 2672

  
2673 2673
    if (vs->password) {
2674
        qemu_free(vs->password);
2674
        g_free(vs->password);
2675 2675
        vs->password = NULL;
2676 2676
    }
2677
    vs->password = qemu_strdup(password);
2677
    vs->password = g_strdup(password);
2678 2678
    vs->auth = VNC_AUTH_VNC;
2679 2679
out:
2680 2680
    if (ret != 0) {
......
2753 2753
            end = strchr(options, ',');
2754 2754
            if (start && (!end || (start < end))) {
2755 2755
                int len = end ? end-(start+1) : strlen(start+1);
2756
                char *path = qemu_strndup(start + 1, len);
2756
                char *path = g_strndup(start + 1, len);
2757 2757

  
2758 2758
                VNC_DEBUG("Trying certificate path '%s'\n", path);
2759 2759
                if (vnc_tls_set_x509_creds_dir(vs, path) < 0) {
2760 2760
                    fprintf(stderr, "Failed to find x509 certificates/keys in %s\n", path);
2761
                    qemu_free(path);
2762
                    qemu_free(vs->display);
2761
                    g_free(path);
2762
                    g_free(vs->display);
2763 2763
                    vs->display = NULL;
2764 2764
                    return -1;
2765 2765
                }
2766
                qemu_free(path);
2766
                g_free(path);
2767 2767
            } else {
2768 2768
                fprintf(stderr, "No certificate path provided\n");
2769
                qemu_free(vs->display);
2769
                g_free(vs->display);
2770 2770
                vs->display = NULL;
2771 2771
                return -1;
2772 2772
            }
......
2907 2907
    } else {
2908 2908
        /* listen for connects */
2909 2909
        char *dpy;
2910
        dpy = qemu_malloc(256);
2910
        dpy = g_malloc(256);
2911 2911
        if (strncmp(display, "unix:", 5) == 0) {
2912 2912
            pstrcpy(dpy, 256, "unix:");
2913 2913
            vs->lsock = unix_listen(display+5, dpy+5, 256-5);

Also available in: Unified diff