|
From: | Richard Henderson |
Subject: | Re: [PATCH 4/9] util/oslib-win32: Return NULL on qemu_try_memalign() with zero size |
Date: | Thu, 3 Mar 2022 13:02:01 -1000 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 |
On 3/3/22 06:55, Peter Maydell wrote:
Alternately, force size == 1, so that we always get a non-NULL value that can be freed. That's a change on the POSIX side as well, of course.Yes, I had a look at what actual malloc() implementations tend to do, and the answer seems to be that forcing size to 1 gives less weird behaviour for the application. So here that would be if (size == 0) { size++; } ptr = _aligned_malloc(size, alignment); We don't need to do anything on the POSIX side (unless we want to enforce consistency of handling the size==0 case).
I would do this unconditionally. The POSIX manpage says that either NULL or a unique pointer is a valid return value into *memptr here for size == 0. What we want in our caller is NULL if and only if error.
I'd quite like to get this series in before softfreeze (though mostly just for my personal convenience so it's not hanging around as a loose end I have to come back to after we reopen for 7.1). Does anybody object if I squash in that change and put this in a pullrequest, or would you prefer to see a v2 series first?
I'm happy with a squash and PR. r~
[Prev in Thread] | Current Thread | [Next in Thread] |