free() does not call sbrk()
Mon Sep 21 06:45:00 GMT 2009
> The point I'm trying to make is that two different ports using the mallocr.c
> code and your test case work fine. The only obvious difference is that you
> have some additional functions with UART_ in front of them that are not part
> of newlib. One or more of these additional functions may be touching the
> heap or are corrupting the call to free() somehow. You might have a bug in
> the compiler used to build newlib or your test. There may even be a bug in
> mallocr that nobody has ever seen before. It's going to take some debugging
> on your part.
> I suggest you debug the test case to ensure that the newlib mallocr code is
> being called for malloc and free, that the ptr passed to free is the same
> one you got from malloc earlier, and that there are no other heap calls
> being made in between directly or indirectly by the UART functions. Failing
> that, try debugging mallocr to see why malloc/free aren't reusing the same
> piece of storage.
Hi Jeff, thanks for making this clear. I found out that our compiler
produces wrong code when using -Ox, for x > 0.
More information about the Newlib