aboutsummaryrefslogtreecommitdiff
path: root/qemu-char.c
diff options
context:
space:
mode:
Diffstat (limited to 'qemu-char.c')
-rw-r--r--qemu-char.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/qemu-char.c b/qemu-char.c
index e4eb985b57..7e4bd9072a 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -91,6 +91,12 @@
static QTAILQ_HEAD(CharDriverStateHead, CharDriverState) chardevs =
QTAILQ_HEAD_INITIALIZER(chardevs);
+CharDriverState *qemu_chr_alloc(void)
+{
+ CharDriverState *chr = g_malloc0(sizeof(CharDriverState));
+ return chr;
+}
+
void qemu_chr_be_event(CharDriverState *s, int event)
{
/* Keep track if the char device is open */
@@ -282,7 +288,7 @@ static CharDriverState *qemu_chr_open_null(void)
{
CharDriverState *chr;
- chr = g_malloc0(sizeof(CharDriverState));
+ chr = qemu_chr_alloc();
chr->chr_write = null_chr_write;
chr->explicit_be_open = true;
return chr;
@@ -570,7 +576,7 @@ static CharDriverState *qemu_chr_open_mux(CharDriverState *drv)
CharDriverState *chr;
MuxDriver *d;
- chr = g_malloc0(sizeof(CharDriverState));
+ chr = qemu_chr_alloc();
d = g_malloc0(sizeof(MuxDriver));
chr->opaque = d;
@@ -945,7 +951,7 @@ static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out)
CharDriverState *chr;
FDCharDriver *s;
- chr = g_malloc0(sizeof(CharDriverState));
+ chr = qemu_chr_alloc();
s = g_malloc0(sizeof(FDCharDriver));
s->fd_in = io_channel_from_fd(fd_in);
s->fd_out = io_channel_from_fd(fd_out);
@@ -1222,7 +1228,7 @@ static CharDriverState *qemu_chr_open_pty(const char *id,
close(slave_fd);
- chr = g_malloc0(sizeof(CharDriverState));
+ chr = qemu_chr_alloc();
chr->filename = g_strdup_printf("pty:%s", pty_name);
ret->pty = g_strdup(pty_name);
@@ -1584,7 +1590,7 @@ static CharDriverState *qemu_chr_open_pp_fd(int fd)
drv->fd = fd;
drv->mode = IEEE1284_MODE_COMPAT;
- chr = g_malloc0(sizeof(CharDriverState));
+ chr = qemu_chr_alloc();
chr->chr_write = null_chr_write;
chr->chr_ioctl = pp_ioctl;
chr->chr_close = pp_close;
@@ -1639,7 +1645,7 @@ static CharDriverState *qemu_chr_open_pp_fd(int fd)
{
CharDriverState *chr;
- chr = g_malloc0(sizeof(CharDriverState));
+ chr = qemu_chr_alloc();
chr->opaque = (void *)(intptr_t)fd;
chr->chr_write = null_chr_write;
chr->chr_ioctl = pp_ioctl;
@@ -1863,7 +1869,7 @@ static CharDriverState *qemu_chr_open_win_path(const char *filename)
CharDriverState *chr;
WinCharState *s;
- chr = g_malloc0(sizeof(CharDriverState));
+ chr = qemu_chr_alloc();
s = g_malloc0(sizeof(WinCharState));
chr->opaque = s;
chr->chr_write = win_chr_write;
@@ -1962,7 +1968,7 @@ static CharDriverState *qemu_chr_open_pipe(ChardevHostdev *opts)
CharDriverState *chr;
WinCharState *s;
- chr = g_malloc0(sizeof(CharDriverState));
+ chr = qemu_chr_alloc();
s = g_malloc0(sizeof(WinCharState));
chr->opaque = s;
chr->chr_write = win_chr_write;
@@ -1981,7 +1987,7 @@ static CharDriverState *qemu_chr_open_win_file(HANDLE fd_out)
CharDriverState *chr;
WinCharState *s;
- chr = g_malloc0(sizeof(CharDriverState));
+ chr = qemu_chr_alloc();
s = g_malloc0(sizeof(WinCharState));
s->hcom = fd_out;
chr->opaque = s;
@@ -2137,7 +2143,7 @@ static CharDriverState *qemu_chr_open_stdio(ChardevStdio *opts)
DWORD dwMode;
int is_console = 0;
- chr = g_malloc0(sizeof(CharDriverState));
+ chr = qemu_chr_alloc();
stdio = g_malloc0(sizeof(WinStdioCharState));
stdio->hStdIn = GetStdHandle(STD_INPUT_HANDLE);
@@ -2299,7 +2305,7 @@ static CharDriverState *qemu_chr_open_udp_fd(int fd)
CharDriverState *chr = NULL;
NetCharDriver *s = NULL;
- chr = g_malloc0(sizeof(CharDriverState));
+ chr = qemu_chr_alloc();
s = g_malloc0(sizeof(NetCharDriver));
s->fd = fd;
@@ -2850,7 +2856,7 @@ static CharDriverState *qemu_chr_open_socket_fd(int fd, bool do_nodelay,
return NULL;
}
- chr = g_malloc0(sizeof(CharDriverState));
+ chr = qemu_chr_alloc();
s = g_malloc0(sizeof(TCPCharDriver));
s->connected = 0;
@@ -3040,7 +3046,7 @@ static CharDriverState *qemu_chr_open_ringbuf(ChardevRingbuf *opts,
CharDriverState *chr;
RingBufCharDriver *d;
- chr = g_malloc0(sizeof(CharDriverState));
+ chr = qemu_chr_alloc();
d = g_malloc(sizeof(*d));
d->size = opts->has_size ? opts->size : 65536;