From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47400) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aggkJ-00047b-NS for qemu-devel@nongnu.org; Thu, 17 Mar 2016 18:50:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aggkG-0008Pv-Go for qemu-devel@nongnu.org; Thu, 17 Mar 2016 18:50:23 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:34604) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aggkG-0008Pm-AC for qemu-devel@nongnu.org; Thu, 17 Mar 2016 18:50:20 -0400 Received: by mail-wm0-x244.google.com with SMTP id p65so2563172wmp.1 for ; Thu, 17 Mar 2016 15:50:20 -0700 (PDT) Sender: Paolo Bonzini References: <1458057598-11041-1-git-send-email-dhannawatpooja1@gmail.com> <20160317145025.GN14062@stefanha-x1.localdomain> From: Paolo Bonzini Message-ID: <56EB34A7.9030601@redhat.com> Date: Thu, 17 Mar 2016 23:50:15 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v4] socket: Allocating Large sized arrays to heap List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pooja Dhannawat , Stefan Hajnoczi Cc: qemu-devel@nongnu.org On 17/03/2016 16:31, Pooja Dhannawat wrote: > > > On Thu, Mar 17, 2016 at 8:20 PM, Stefan Hajnoczi > wrote: > > On Tue, Mar 15, 2016 at 09:29:58PM +0530, Pooja Dhannawat wrote: > > @@ -170,8 +170,8 @@ 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)); > > This change is unrelated to allocating buf1 on the heap. What is the > purpose of this line? > > > I moved buf from stack to Heap, used g_new(), but I got your point if we > need to initialize it with 0 then I have to keep that one. > > Other wise doing so it gets whatever garbage it has already. This is s->buf, not buf. Also, the BiteSizedTasks page says "Make the stack array smaller and allocate on the heap in the rare case that the data does not fit in the small array". Paolo