Re: [Qemu-devel] [PATCH v4] socket: Allocating Large sized arrays to hea
From:
Pooja Dhannawat
Subject:
Re: [Qemu-devel] [PATCH v4] socket: Allocating Large sized arrays to heap
Date:
Fri, 18 Mar 2016 21:28:04 +0530
On Friday, March 18, 2016, Paolo Bonzini <address@hidden> wrote: > > > On 18/03/2016 14:49, Pooja Dhannawat wrote: >> >> >> If it is greater than the accepted level, the on-stack >> buffer is not >> used and you allocate one that has the right size on the heap. >> >> Yes Okay. Thank you for the comments. >> I had one more question. >> size = qemu_recv(s->fd, buf1, sizeof(buf1), 0); >> The one above returns bytes read into buf1 (if large then bytes >> equivalent to len(buf1) is read) ? >> If true, size is the correct measure of buf1? Hence, I should >> compare the allowed stack size to "size" variable? >> >> So isnt here size should be compared to "size" varibale paolo? >> >> So instead of comparing with NET_BUFSIZE, should I compare with "size" >> variable? Can you help me with this? > > I was a bit confused myself; this function actually is a bit different > from the others because it does not really need a large buffer. The > function already takes care of moving data in pieces from buf1 to > s->buf. If you make the buffer smaller, the only change is that one > call to net_socket_send will process fewer bytes. > > So you can just send a trivial patch that changes the size of the array > to something like 2048. > > Thanks, and sorry for putting you on a false track! > No, it's completely fine, I really appreciate your help. > Paolo >