[En-Nut-Discussion] NutHeapAvailable() question

Alexander Baranov baranov at intech21.com
Wed Sep 27 21:02:46 CEST 2006


Hi Harald.
But I don't use variable with name 'available'. How can your 'available' 
interfere me? Maybe I use wrong format string - %u for size_t?
Regards
Alexander.
----- Original Message ----- 
From: "Harald Kipp" <harald.kipp at egnite.de>
To: "Ethernut User Chat (English)" <en-nut-discussion at egnite.de>
Sent: Wednesday, September 27, 2006 2:05 PM
Subject: Re: [En-Nut-Discussion] NutHeapAvailable() question


> 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
>
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
> 




More information about the En-Nut-Discussion mailing list