[En-Nut-Discussion] NutHeapAvailable() question

Harald Kipp harald.kipp at egnite.de
Wed Sep 27 20:05:34 CEST 2006


Alexander,

At 17:26 26.09.2006 -0400, you wrote:
>Hello all.
>I have been using NutHeapAvailable() for a long time but suddenly noticed 
>that it started returning negative values.
>Command
>fprintf(uart, "Heap available = %u  \r\n", (unsigned int)NutHeapAvailable() );
>returns -1830.
>What has changed since old times?

I think, the type of the return value has changed from u_short to
size_t some time ago. But that should not provide negative values.

However, I can see in os/heap.c that

    size_t available = 0;

is a public global, which is extremely bad for such a common
name.

Further, the initializer is bad too. It occupies two or four
additional bytes in the data segment. Try to change this to

    static size_t available;

Harald




More information about the En-Nut-Discussion mailing list