yamt commented on PR #14348:
URL: https://github.com/apache/nuttx/pull/14348#issuecomment-2415754141
> Sorry, my commit message may not be clear enough.
>
> > > The malloc() function allocates size bytes and returns a pointer to
the allocated memory. The memory is not initialized. If size is 0, then
malloc() returns a unique pointer value that can later be successfully passed
to free().
> >
> >
> > do you mean to require host malloc to follow the specific behavior? why?
>
> I want to align the behavior of sim_heap(Customized heap manager) and
mm_heap(Default heap manager).
>
> The default heap management in nuttx returns a valid memory address when
malloc(0), In sim_heap, malloc(0) returns NULL. This PR makes malloc(0) in
sim_heap return a valid pointer
to me, this PR seems to make it return whatever host_realloc(..., 0) returns.
depending on the host os, it might or might not be NULL.
am i missing something?
if you want to make it return non-NULL, the usual trick is `if (size == 0) {
size = 1; }`.
> > > (See "Nonportable behavior" for portability issues.)
> >
> >
> > what exactly are you referring to here?
>
> This part is an excerpt from the man manual,It might be missing some
context, I've updated the commit message
ok. please don't forget that not everyone uses linux.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]