Received: from eggs.gnu.org ([2001:4830:134:3::10]:43212) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afHJA-0003Z8-Qv for qemu-devel@nongnu.org; Sun, 13 Mar 2016 21:28:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1afHJ7-0006ov-Lk for qemu-devel@nongnu.org; Sun, 13 Mar 2016 21:28:32 -0400 Received: from [59.151.112.132] (port=11155 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afHJ7-0006mf-9n for qemu-devel@nongnu.org; Sun, 13 Mar 2016 21:28:29 -0400 References: <1457753338-22089-1-git-send-email-dhannawatpooja1@gmail.com> From: Li Zhijian Message-ID: <56E613A5.2070807@cn.fujitsu.com> Date: Mon, 14 Mar 2016 09:28:05 +0800 MIME-Version: 1.0 In-Reply-To: <1457753338-22089-1-git-send-email-dhannawatpooja1@gmail.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [Patch 1/1] net/socket: Allocating Large sized arrays to heap List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pooja Dhannawat , qemu-devel@nongnu.org Don't get why we need this changes, could you explain more for it? and it seem it's not exactly correct, see below. On 03/12/2016 11:28 AM, Pooja Dhannawat wrote: > Signed-off-by: Pooja Dhannawat > --- > net/socket.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/net/socket.c b/net/socket.c > index e32e3cb..483dcac 100644 > --- a/net/socket.c > +++ b/net/socket.c > @@ -147,10 +147,10 @@ static void net_socket_send(void *opaque) > NetSocketState *s = opaque; > int size, err; > unsigned l; > - uint8_t buf1[NET_BUFSIZE]; > + uint8_t *buf1 = g_new(uint8_t, 1); > const uint8_t *buf; > > - size = qemu_recv(s->fd, buf1, sizeof(buf1), 0); > + size = qemu_recv(s->fd, (uint8_t *)buf1, sizeof(uint8_t), 0); one byte for each reading, it looks expensive > if (size < 0) { > err = socket_error(); > if (err != EWOULDBLOCK) > @@ -170,7 +170,6 @@ static void net_socket_send(void *opaque) > s->index = 0; > s->packet_len = 0; > s->nc.link_down = true; > - memset(s->buf, 0, sizeof(s->buf)); > memset(s->nc.info_str, 0, sizeof(s->nc.info_str)); > forget to release buf1. Thanks Li ZHijian > return; > @@ -222,6 +221,7 @@ static void net_socket_send(void *opaque) > break; > } > } > + g_free(buf1); > } > > static void net_socket_send_dgram(void *opaque) >