aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2011-08-20 22:09:37 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2011-08-20 23:01:08 -0500
commit7267c0947d7e8ae5dff7bafd932c3bc285f43e5c (patch)
tree9aa05d6e05ed83e67bf014f6745a3081b8407dc5 /ui
parent14015304b662e8f8ccce46c5a6927af6a14c510b (diff)
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/curses.c2
-rw-r--r--ui/keymaps.c6
-rw-r--r--ui/sdl.c20
-rw-r--r--ui/spice-core.c30
-rw-r--r--ui/spice-display.c12
-rw-r--r--ui/spice-input.c4
-rw-r--r--ui/vnc-auth-sasl.c2
-rw-r--r--ui/vnc-enc-hextile.c4
-rw-r--r--ui/vnc-enc-tight.c12
-rw-r--r--ui/vnc-enc-zlib.c4
-rw-r--r--ui/vnc-jobs-async.c14
-rw-r--r--ui/vnc-palette.c4
-rw-r--r--ui/vnc-tls.c18
-rw-r--r--ui/vnc.c54
14 files changed, 93 insertions, 93 deletions
diff --git a/ui/curses.c b/ui/curses.c
index d29b6cf874..c2be2c641a 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -354,7 +354,7 @@ void curses_display_init(DisplayState *ds, int full_screen)
#endif
#endif
- dcl = (DisplayChangeListener *) qemu_mallocz(sizeof(DisplayChangeListener));
+ dcl = (DisplayChangeListener *) g_malloc0(sizeof(DisplayChangeListener));
dcl->dpy_update = curses_update;
dcl->dpy_resize = curses_resize;
dcl->dpy_refresh = curses_refresh;
diff --git a/ui/keymaps.c b/ui/keymaps.c
index 78c7ea375c..81003bb5ca 100644
--- a/ui/keymaps.c
+++ b/ui/keymaps.c
@@ -52,7 +52,7 @@ static void add_to_key_range(struct key_range **krp, int code) {
}
}
if (kr == NULL) {
- kr = qemu_mallocz(sizeof(*kr));
+ kr = g_malloc0(sizeof(*kr));
kr->start = kr->end = code;
kr->next = *krp;
*krp = kr;
@@ -94,13 +94,13 @@ static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table,
filename = qemu_find_file(QEMU_FILE_TYPE_KEYMAP, language);
if (!k)
- k = qemu_mallocz(sizeof(kbd_layout_t));
+ k = g_malloc0(sizeof(kbd_layout_t));
if (!(filename && (f = fopen(filename, "r")))) {
fprintf(stderr,
"Could not read keymap file: '%s'\n", language);
return NULL;
}
- qemu_free(filename);
+ g_free(filename);
for(;;) {
if (fgets(line, 1024, f) == NULL)
break;
diff --git a/ui/sdl.c b/ui/sdl.c
index 30cde8662e..385cc91279 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -166,7 +166,7 @@ static PixelFormat sdl_to_qemu_pixelformat(SDL_PixelFormat *sdl_pf)
static DisplaySurface* sdl_create_displaysurface(int width, int height)
{
- DisplaySurface *surface = (DisplaySurface*) qemu_mallocz(sizeof(DisplaySurface));
+ DisplaySurface *surface = (DisplaySurface*) g_malloc0(sizeof(DisplaySurface));
if (surface == NULL) {
fprintf(stderr, "sdl_create_displaysurface: malloc failed\n");
exit(1);
@@ -215,8 +215,8 @@ static void sdl_free_displaysurface(DisplaySurface *surface)
return;
if (surface->flags & QEMU_ALLOCATED_FLAG)
- qemu_free(surface->data);
- qemu_free(surface);
+ g_free(surface->data);
+ g_free(surface);
}
static DisplaySurface* sdl_resize_displaysurface(DisplaySurface *surface, int width, int height)
@@ -928,14 +928,14 @@ static void sdl_mouse_define(QEMUCursor *c)
SDL_FreeCursor(guest_sprite);
bpl = cursor_get_mono_bpl(c);
- image = qemu_mallocz(bpl * c->height);
- mask = qemu_mallocz(bpl * c->height);
+ image = g_malloc0(bpl * c->height);
+ mask = g_malloc0(bpl * c->height);
cursor_get_mono_image(c, 0x000000, image);
cursor_get_mono_mask(c, 0, mask);
guest_sprite = SDL_CreateCursor(image, mask, c->width, c->height,
c->hot_x, c->hot_y);
- qemu_free(image);
- qemu_free(mask);
+ g_free(image);
+ g_free(mask);
if (guest_cursor &&
(gui_grab || kbd_mouse_is_absolute() || absolute_enabled))
@@ -1009,7 +1009,7 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
SDL_SetColorKey(image, SDL_SRCCOLORKEY, colorkey);
SDL_WM_SetIcon(image, NULL);
}
- qemu_free(filename);
+ g_free(filename);
}
if (full_screen) {
@@ -1017,7 +1017,7 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
sdl_grab_start();
}
- dcl = qemu_mallocz(sizeof(DisplayChangeListener));
+ dcl = g_malloc0(sizeof(DisplayChangeListener));
dcl->dpy_update = sdl_update;
dcl->dpy_resize = sdl_resize;
dcl->dpy_refresh = sdl_refresh;
@@ -1027,7 +1027,7 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
ds->cursor_define = sdl_mouse_define;
register_displaychangelistener(ds, dcl);
- da = qemu_mallocz(sizeof(DisplayAllocator));
+ da = g_malloc0(sizeof(DisplayAllocator));
da->create_displaysurface = sdl_create_displaysurface;
da->resize_displaysurface = sdl_resize_displaysurface;
da->free_displaysurface = sdl_free_displaysurface;
diff --git a/ui/spice-core.c b/ui/spice-core.c
index 8bb62eaa01..dba11f0c33 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -54,7 +54,7 @@ static SpiceTimer *timer_add(SpiceTimerFunc func, void *opaque)
{
SpiceTimer *timer;
- timer = qemu_mallocz(sizeof(*timer));
+ timer = g_malloc0(sizeof(*timer));
timer->timer = qemu_new_timer_ms(rt_clock, func, opaque);
QTAILQ_INSERT_TAIL(&timers, timer, next);
return timer;
@@ -75,7 +75,7 @@ static void timer_remove(SpiceTimer *timer)
qemu_del_timer(timer->timer);
qemu_free_timer(timer->timer);
QTAILQ_REMOVE(&timers, timer, next);
- qemu_free(timer);
+ g_free(timer);
}
struct SpiceWatch {
@@ -118,7 +118,7 @@ static SpiceWatch *watch_add(int fd, int event_mask, SpiceWatchFunc func, void *
{
SpiceWatch *watch;
- watch = qemu_mallocz(sizeof(*watch));
+ watch = g_malloc0(sizeof(*watch));
watch->fd = fd;
watch->func = func;
watch->opaque = opaque;
@@ -132,7 +132,7 @@ static void watch_remove(SpiceWatch *watch)
{
watch_update_mask(watch, 0);
QTAILQ_REMOVE(&watches, watch, next);
- qemu_free(watch);
+ g_free(watch);
}
#if SPICE_INTERFACE_CORE_MINOR >= 3
@@ -148,7 +148,7 @@ static void channel_list_add(SpiceChannelEventInfo *info)
{
ChannelList *item;
- item = qemu_mallocz(sizeof(*item));
+ item = g_malloc0(sizeof(*item));
item->info = info;
QTAILQ_INSERT_TAIL(&channel_list, item, link);
}
@@ -162,7 +162,7 @@ static void channel_list_del(SpiceChannelEventInfo *info)
continue;
}
QTAILQ_REMOVE(&channel_list, item, link);
- qemu_free(item);
+ g_free(item);
return;
}
}
@@ -510,25 +510,25 @@ void qemu_spice_init(void)
str = qemu_opt_get(opts, "x509-key-file");
if (str) {
- x509_key_file = qemu_strdup(str);
+ x509_key_file = g_strdup(str);
} else {
- x509_key_file = qemu_malloc(len);
+ x509_key_file = g_malloc(len);
snprintf(x509_key_file, len, "%s/%s", x509_dir, X509_SERVER_KEY_FILE);
}
str = qemu_opt_get(opts, "x509-cert-file");
if (str) {
- x509_cert_file = qemu_strdup(str);
+ x509_cert_file = g_strdup(str);
} else {
- x509_cert_file = qemu_malloc(len);
+ x509_cert_file = g_malloc(len);
snprintf(x509_cert_file, len, "%s/%s", x509_dir, X509_SERVER_CERT_FILE);
}
str = qemu_opt_get(opts, "x509-cacert-file");
if (str) {
- x509_cacert_file = qemu_strdup(str);
+ x509_cacert_file = g_strdup(str);
} else {
- x509_cacert_file = qemu_malloc(len);
+ x509_cacert_file = g_malloc(len);
snprintf(x509_cacert_file, len, "%s/%s", x509_dir, X509_CA_CERT_FILE);
}
@@ -631,9 +631,9 @@ void qemu_spice_init(void)
qemu_spice_input_init();
qemu_spice_audio_init();
- qemu_free(x509_key_file);
- qemu_free(x509_cert_file);
- qemu_free(x509_cacert_file);
+ g_free(x509_key_file);
+ g_free(x509_cert_file);
+ g_free(x509_cacert_file);
}
int qemu_spice_add_interface(SpiceBaseInstance *sin)
diff --git a/ui/spice-display.c b/ui/spice-display.c
index 683d45429f..498396332c 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -144,14 +144,14 @@ static SimpleSpiceUpdate *qemu_spice_create_update(SimpleSpiceDisplay *ssd)
ssd->dirty.left, ssd->dirty.right,
ssd->dirty.top, ssd->dirty.bottom);
- update = qemu_mallocz(sizeof(*update));
+ update = g_malloc0(sizeof(*update));
drawable = &update->drawable;
image = &update->image;
cmd = &update->ext.cmd;
bw = ssd->dirty.right - ssd->dirty.left;
bh = ssd->dirty.bottom - ssd->dirty.top;
- update->bitmap = qemu_malloc(bw * bh * 4);
+ update->bitmap = g_malloc(bw * bh * 4);
drawable->bbox = ssd->dirty;
drawable->clip.type = SPICE_CLIP_TYPE_NONE;
@@ -208,12 +208,12 @@ static SimpleSpiceUpdate *qemu_spice_create_update(SimpleSpiceDisplay *ssd)
* Called from spice server thread context (via interface_release_ressource)
* We do *not* hold the global qemu mutex here, so extra care is needed
* when calling qemu functions. Qemu interfaces used:
- * - qemu_free (underlying glibc free is re-entrant).
+ * - g_free (underlying glibc free is re-entrant).
*/
void qemu_spice_destroy_update(SimpleSpiceDisplay *sdpy, SimpleSpiceUpdate *update)
{
- qemu_free(update->bitmap);
- qemu_free(update);
+ g_free(update->bitmap);
+ g_free(update);
}
void qemu_spice_create_host_memslot(SimpleSpiceDisplay *ssd)
@@ -274,7 +274,7 @@ void qemu_spice_display_init_common(SimpleSpiceDisplay *ssd, DisplayState *ds)
ssd->mouse_x = -1;
ssd->mouse_y = -1;
ssd->bufsize = (16 * 1024 * 1024);
- ssd->buf = qemu_malloc(ssd->bufsize);
+ ssd->buf = g_malloc(ssd->bufsize);
}
/* display listener callbacks */
diff --git a/ui/spice-input.c b/ui/spice-input.c
index 75abf5fbe9..af4223d442 100644
--- a/ui/spice-input.c
+++ b/ui/spice-input.c
@@ -200,12 +200,12 @@ void qemu_spice_input_init(void)
QemuSpiceKbd *kbd;
QemuSpicePointer *pointer;
- kbd = qemu_mallocz(sizeof(*kbd));
+ kbd = g_malloc0(sizeof(*kbd));
kbd->sin.base.sif = &kbd_interface.base;
qemu_spice_add_interface(&kbd->sin.base);
qemu_add_led_event_handler(kbd_leds, kbd);
- pointer = qemu_mallocz(sizeof(*pointer));
+ pointer = g_malloc0(sizeof(*pointer));
pointer->mouse.base.sif = &mouse_interface.base;
pointer->tablet.base.sif = &tablet_interface.base;
qemu_spice_add_interface(&pointer->mouse.base);
diff --git a/ui/vnc-auth-sasl.c b/ui/vnc-auth-sasl.c
index 15af49bdb1..e96095ab94 100644
--- a/ui/vnc-auth-sasl.c
+++ b/ui/vnc-auth-sasl.c
@@ -135,7 +135,7 @@ static int vnc_auth_sasl_check_access(VncState *vs)
}
VNC_DEBUG("SASL client username %s\n", (const char *)val);
- vs->sasl.username = qemu_strdup((const char*)val);
+ vs->sasl.username = g_strdup((const char*)val);
if (vs->vd->sasl.acl == NULL) {
VNC_DEBUG("no ACL activated, allowing access\n");
diff --git a/ui/vnc-enc-hextile.c b/ui/vnc-enc-hextile.c
index 364a491157..d2905c88f0 100644
--- a/ui/vnc-enc-hextile.c
+++ b/ui/vnc-enc-hextile.c
@@ -70,8 +70,8 @@ int vnc_hextile_send_framebuffer_update(VncState *vs, int x,
uint8_t *last_fg, *last_bg;
VncDisplay *vd = vs->vd;
- last_fg = (uint8_t *) qemu_malloc(vd->server->pf.bytes_per_pixel);
- last_bg = (uint8_t *) qemu_malloc(vd->server->pf.bytes_per_pixel);
+ last_fg = (uint8_t *) g_malloc(vd->server->pf.bytes_per_pixel);
+ last_bg = (uint8_t *) g_malloc(vd->server->pf.bytes_per_pixel);
has_fg = has_bg = 0;
for (j = y; j < (y + h); j += 16) {
for (i = x; i < (x + w); i += 16) {
diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c
index 5c02803411..5d492abe92 100644
--- a/ui/vnc-enc-tight.c
+++ b/ui/vnc-enc-tight.c
@@ -1293,13 +1293,13 @@ static int send_jpeg_rect(VncState *vs, int x, int y, int w, int h, int quality)
jpeg_start_compress(&cinfo, true);
- buf = qemu_malloc(w * 3);
+ buf = g_malloc(w * 3);
row[0] = buf;
for (dy = 0; dy < h; dy++) {
rgb_prepare_row(vs, buf, x, y + dy, w);
jpeg_write_scanlines(&cinfo, row, 1);
}
- qemu_free(buf);
+ g_free(buf);
jpeg_finish_compress(&cinfo);
jpeg_destroy_compress(&cinfo);
@@ -1363,12 +1363,12 @@ static void png_flush_data(png_structp png_ptr)
static void *vnc_png_malloc(png_structp png_ptr, png_size_t size)
{
- return qemu_malloc(size);
+ return g_malloc(size);
}
static void vnc_png_free(png_structp png_ptr, png_voidp ptr)
{
- qemu_free(ptr);
+ g_free(ptr);
}
static int send_png_rect(VncState *vs, int x, int y, int w, int h,
@@ -1432,7 +1432,7 @@ static int send_png_rect(VncState *vs, int x, int y, int w, int h,
png_write_info(png_ptr, info_ptr);
buffer_reserve(&vs->tight.png, 2048);
- buf = qemu_malloc(w * 3);
+ buf = g_malloc(w * 3);
for (dy = 0; dy < h; dy++)
{
if (color_type == PNG_COLOR_TYPE_PALETTE) {
@@ -1442,7 +1442,7 @@ static int send_png_rect(VncState *vs, int x, int y, int w, int h,
}
png_write_row(png_ptr, buf);
}
- qemu_free(buf);
+ g_free(buf);
png_write_end(png_ptr, NULL);
diff --git a/ui/vnc-enc-zlib.c b/ui/vnc-enc-zlib.c
index e32e4cd8a8..d1b97f2516 100644
--- a/ui/vnc-enc-zlib.c
+++ b/ui/vnc-enc-zlib.c
@@ -35,14 +35,14 @@ void *vnc_zlib_zalloc(void *x, unsigned items, unsigned size)
size *= items;
size = (size + ZALLOC_ALIGNMENT - 1) & ~(ZALLOC_ALIGNMENT - 1);
- p = qemu_mallocz(size);
+ p = g_malloc0(size);
return (p);
}
void vnc_zlib_zfree(void *x, void *addr)
{
- qemu_free(addr);
+ g_free(addr);
}
static void vnc_zlib_start(VncState *vs)
diff --git a/ui/vnc-jobs-async.c b/ui/vnc-jobs-async.c
index 1dfa6c3c9e..de5ea6b5d8 100644
--- a/ui/vnc-jobs-async.c
+++ b/ui/vnc-jobs-async.c
@@ -77,7 +77,7 @@ static void vnc_unlock_queue(VncJobQueue *queue)
VncJob *vnc_job_new(VncState *vs)
{
- VncJob *job = qemu_mallocz(sizeof(VncJob));
+ VncJob *job = g_malloc0(sizeof(VncJob));
job->vs = vs;
vnc_lock_queue(queue);
@@ -88,7 +88,7 @@ VncJob *vnc_job_new(VncState *vs)
int vnc_job_add_rect(VncJob *job, int x, int y, int w, int h)
{
- VncRectEntry *entry = qemu_mallocz(sizeof(VncRectEntry));
+ VncRectEntry *entry = g_malloc0(sizeof(VncRectEntry));
entry->rect.x = x;
entry->rect.y = y;
@@ -105,7 +105,7 @@ void vnc_job_push(VncJob *job)
{
vnc_lock_queue(queue);
if (queue->exit || QLIST_EMPTY(&job->rectangles)) {
- qemu_free(job);
+ g_free(job);
} else {
QTAILQ_INSERT_TAIL(&queue->jobs, job, next);
qemu_cond_broadcast(&queue->cond);
@@ -246,7 +246,7 @@ static int vnc_worker_thread_loop(VncJobQueue *queue)
if (n >= 0) {
n_rectangles += n;
}
- qemu_free(entry);
+ g_free(entry);
}
vnc_unlock_display(job->vs->vd);
@@ -276,13 +276,13 @@ disconnected:
QTAILQ_REMOVE(&queue->jobs, job, next);
vnc_unlock_queue(queue);
qemu_cond_broadcast(&queue->cond);
- qemu_free(job);
+ g_free(job);
return 0;
}
static VncJobQueue *vnc_queue_init(void)
{
- VncJobQueue *queue = qemu_mallocz(sizeof(VncJobQueue));
+ VncJobQueue *queue = g_malloc0(sizeof(VncJobQueue));
qemu_cond_init(&queue->cond);
qemu_mutex_init(&queue->mutex);
@@ -295,7 +295,7 @@ static void vnc_queue_clear(VncJobQueue *q)
qemu_cond_destroy(&queue->cond);
qemu_mutex_destroy(&queue->mutex);
buffer_free(&queue->buffer);
- qemu_free(q);
+ g_free(q);
queue = NULL; /* Unset global queue */
}
diff --git a/ui/vnc-palette.c b/ui/vnc-palette.c
index 13ece42160..63d5f64917 100644
--- a/ui/vnc-palette.c
+++ b/ui/vnc-palette.c
@@ -55,7 +55,7 @@ VncPalette *palette_new(size_t max, int bpp)
{
VncPalette *palette;
- palette = qemu_mallocz(sizeof(*palette));
+ palette = g_malloc0(sizeof(*palette));
palette_init(palette, max, bpp);
return palette;
}
@@ -69,7 +69,7 @@ void palette_init(VncPalette *palette, size_t max, int bpp)
void palette_destroy(VncPalette *palette)
{
- qemu_free(palette);
+ g_free(palette);
}
int palette_put(VncPalette *palette, uint32_t color)
diff --git a/ui/vnc-tls.c b/ui/vnc-tls.c
index 31f1467ad0..2e2456e3ac 100644
--- a/ui/vnc-tls.c
+++ b/ui/vnc-tls.c
@@ -244,11 +244,11 @@ int vnc_tls_validate_certificate(struct VncState *vs)
if (i == 0) {
size_t dnameSize = 1024;
- vs->tls.dname = qemu_malloc(dnameSize);
+ vs->tls.dname = g_malloc(dnameSize);
requery:
if ((ret = gnutls_x509_crt_get_dn (cert, vs->tls.dname, &dnameSize)) != 0) {
if (ret == GNUTLS_E_SHORT_MEMORY_BUFFER) {
- vs->tls.dname = qemu_realloc(vs->tls.dname, dnameSize);
+ vs->tls.dname = g_realloc(vs->tls.dname, dnameSize);
goto requery;
}
gnutls_x509_crt_deinit (cert);
@@ -397,11 +397,11 @@ static int vnc_set_x509_credential(VncDisplay *vd,
struct stat sb;
if (*cred) {
- qemu_free(*cred);
+ g_free(*cred);
*cred = NULL;
}
- *cred = qemu_malloc(strlen(certdir) + strlen(filename) + 2);
+ *cred = g_malloc(strlen(certdir) + strlen(filename) + 2);
strcpy(*cred, certdir);
strcat(*cred, "/");
@@ -409,7 +409,7 @@ static int vnc_set_x509_credential(VncDisplay *vd,
VNC_DEBUG("Check %s\n", *cred);
if (stat(*cred, &sb) < 0) {
- qemu_free(*cred);
+ g_free(*cred);
*cred = NULL;
if (ignoreMissing && errno == ENOENT)
return 0;
@@ -435,10 +435,10 @@ int vnc_tls_set_x509_creds_dir(VncDisplay *vd,
return 0;
cleanup:
- qemu_free(vd->tls.x509cacert);
- qemu_free(vd->tls.x509cacrl);
- qemu_free(vd->tls.x509cert);
- qemu_free(vd->tls.x509key);
+ g_free(vd->tls.x509cacert);
+ g_free(vd->tls.x509cacrl);
+ g_free(vd->tls.x509cert);
+ g_free(vd->tls.x509key);
vd->tls.x509cacert = vd->tls.x509cacrl = vd->tls.x509cert = vd->tls.x509key = NULL;
return -1;
}
diff --git a/ui/vnc.c b/ui/vnc.c
index f1e27d97b8..fc3a612a35 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -67,7 +67,7 @@ static char *addr_to_string(const char *format,
/* Enough for the existing format + the 2 vars we're
* substituting in. */
addrlen = strlen(format) + strlen(host) + strlen(serv);
- addr = qemu_malloc(addrlen + 1);
+ addr = g_malloc(addrlen + 1);
snprintf(addr, addrlen, format, host, serv);
addr[addrlen] = '\0';
@@ -411,7 +411,7 @@ void buffer_reserve(Buffer *buffer, size_t len)
{
if ((buffer->capacity - buffer->offset) < len) {
buffer->capacity += (len + 1024);
- buffer->buffer = qemu_realloc(buffer->buffer, buffer->capacity);
+ buffer->buffer = g_realloc(buffer->buffer, buffer->capacity);
if (buffer->buffer == NULL) {
fprintf(stderr, "vnc: out of memory\n");
exit(1);
@@ -436,7 +436,7 @@ void buffer_reset(Buffer *buffer)
void buffer_free(Buffer *buffer)
{
- qemu_free(buffer->buffer);
+ g_free(buffer->buffer);
buffer->offset = 0;
buffer->capacity = 0;
buffer->buffer = NULL;
@@ -505,16 +505,16 @@ static void vnc_dpy_resize(DisplayState *ds)
/* server surface */
if (!vd->server)
- vd->server = qemu_mallocz(sizeof(*vd->server));
+ vd->server = g_malloc0(sizeof(*vd->server));
if (vd->server->data)
- qemu_free(vd->server->data);
+ g_free(vd->server->data);
*(vd->server) = *(ds->surface);
- vd->server->data = qemu_mallocz(vd->server->linesize *
+ vd->server->data = g_malloc0(vd->server->linesize *
vd->server->height);
/* guest surface */
if (!vd->guest.ds)
- vd->guest.ds = qemu_mallocz(sizeof(*vd->guest.ds));
+ vd->guest.ds = g_malloc0(sizeof(*vd->guest.ds));
if (ds_get_bytes_per_pixel(ds) != vd->guest.ds->pf.bytes_per_pixel)
console_color_init(ds);
*(vd->guest.ds) = *(ds->surface);
@@ -781,12 +781,12 @@ static void vnc_dpy_cursor_define(QEMUCursor *c)
VncState *vs;
cursor_put(vd->cursor);
- qemu_free(vd->cursor_mask);
+ g_free(vd->cursor_mask);
vd->cursor = c;
cursor_get(vd->cursor);
vd->cursor_msize = cursor_get_mono_bpl(c) * c->height;
- vd->cursor_mask = qemu_mallocz(vd->cursor_msize);
+ vd->cursor_mask = g_malloc0(vd->cursor_msize);
cursor_get_mono_mask(c, 0, vd->cursor_mask);
QTAILQ_FOREACH(vs, &vd->clients, next) {
@@ -1013,10 +1013,10 @@ static void vnc_disconnect_finish(VncState *vs)
qemu_mutex_destroy(&vs->output_mutex);
#endif
for (i = 0; i < VNC_STAT_ROWS; ++i) {
- qemu_free(vs->lossy_rect[i]);
+ g_free(vs->lossy_rect[i]);
}
- qemu_free(vs->lossy_rect);
- qemu_free(vs);
+ g_free(vs->lossy_rect);
+ g_free(vs);
}
int vnc_client_io_error(VncState *vs, int ret, int last_errno)
@@ -2496,7 +2496,7 @@ static void vnc_remove_timer(VncDisplay *vd)
static void vnc_connect(VncDisplay *vd, int csock, int skipauth)
{
- VncState *vs = qemu_mallocz(sizeof(VncState));
+ VncState *vs = g_malloc0(sizeof(VncState));
int i;
vs->csock = csock;
@@ -2513,9 +2513,9 @@ static void vnc_connect(VncDisplay *vd, int csock, int skipauth)
#endif
}
- vs->lossy_rect = qemu_mallocz(VNC_STAT_ROWS * sizeof (*vs->lossy_rect));
+ vs->lossy_rect = g_malloc0(VNC_STAT_ROWS * sizeof (*vs->lossy_rect));
for (i = 0; i < VNC_STAT_ROWS; ++i) {
- vs->lossy_rect[i] = qemu_mallocz(VNC_STAT_COLS * sizeof (uint8_t));
+ vs->lossy_rect[i] = g_malloc0(VNC_STAT_COLS * sizeof (uint8_t));
}
VNC_DEBUG("New client on socket %d\n", csock);
@@ -2576,9 +2576,9 @@ static void vnc_listen_read(void *opaque)
void vnc_display_init(DisplayState *ds)
{
- VncDisplay *vs = qemu_mallocz(sizeof(*vs));
+ VncDisplay *vs = g_malloc0(sizeof(*vs));
- dcl = qemu_mallocz(sizeof(DisplayChangeListener));
+ dcl = g_malloc0(sizeof(DisplayChangeListener));
ds->opaque = vs;
dcl->idle = 1;
@@ -2620,7 +2620,7 @@ void vnc_display_close(DisplayState *ds)
if (!vs)
return;
if (vs->display) {
- qemu_free(vs->display);
+ g_free(vs->display);
vs->display = NULL;
}
if (vs->lsock != -1) {
@@ -2644,7 +2644,7 @@ int vnc_display_disable_login(DisplayState *ds)
}
if (vs->password) {
- qemu_free(vs->password);
+ g_free(vs->password);
}
vs->password = NULL;
@@ -2671,10 +2671,10 @@ int vnc_display_password(DisplayState *ds, const char *password)
}
if (vs->password) {
- qemu_free(vs->password);
+ g_free(vs->password);
vs->password = NULL;
}
- vs->password = qemu_strdup(password);
+ vs->password = g_strdup(password);
vs->auth = VNC_AUTH_VNC;
out:
if (ret != 0) {
@@ -2753,20 +2753,20 @@ int vnc_display_open(DisplayState *ds, const char *display)
end = strchr(options, ',');
if (start && (!end || (start < end))) {
int len = end ? end-(start+1) : strlen(start+1);
- char *path = qemu_strndup(start + 1, len);
+ char *path = g_strndup(start + 1, len);
VNC_DEBUG("Trying certificate path '%s'\n", path);
if (vnc_tls_set_x509_creds_dir(vs, path) < 0) {
fprintf(stderr, "Failed to find x509 certificates/keys in %s\n", path);
- qemu_free(path);
- qemu_free(vs->display);
+ g_free(path);
+ g_free(vs->display);
vs->display = NULL;
return -1;
}
- qemu_free(path);
+ g_free(path);
} else {
fprintf(stderr, "No certificate path provided\n");
- qemu_free(vs->display);
+ g_free(vs->display);
vs->display = NULL;
return -1;
}
@@ -2907,7 +2907,7 @@ int vnc_display_open(DisplayState *ds, const char *display)
} else {
/* listen for connects */
char *dpy;
- dpy = qemu_malloc(256);
+ dpy = g_malloc(256);
if (strncmp(display, "unix:", 5) == 0) {
pstrcpy(dpy, 256, "unix:");
vs->lsock = unix_listen(display+5, dpy+5, 256-5);