Re: [PATCH 2/3] virSysinfoParseX86BaseBoard: Free memory upfront if no board detected

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/10/19 10:08 AM, Peter Krempa wrote:
On Fri, May 10, 2019 at 09:52:27 +0200, Michal Privoznik wrote:
If no board was detected then VIR_REALLOC_N() done at the end of
the function will actually free the memory (because nborads ==
0), but @boards will be set to a non-NULL pointer. This makes it
unnecessary harder for a caller to see if any board was detected.

Ah, yeah. Allocating 0 bytes of memory may get you a pointer.

I'm wondering if it makes sense to modify VIR_REALLOC_N() so that it calls VIR_FREE() if count == 0. If so, then this patch is not needed.

Michal

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux