Whenever the stack/heap configuration is anything other than normal, it is likely that malloc/calloc is not going to work the way you think it should. In particular, when dealing within RTOS that has a separate context of "stack", it is almost assured that malloc won't work.
In FreeRTOS they set aside a separate "heap" that separate routines then allocate/free. Check out their Memory Manager routines. I'm somewhat surprised that AVRX does not provide some solution, even if it is not required. Best regards, Stu Bell DataPlay (DPHI, Inc.) > -----Original Message----- > From: [email protected] > [mailto:[email protected]] > On Behalf Of DarkDragon > Sent: Thursday, April 09, 2009 10:59 PM > To: [email protected] > Subject: Re: [avr-libc-dev] malloc changes > > > Found the source to malloc and it looks like the cause is the > following code inserted in AVR LibC 1.6.5: > > if (cp <= __brkval) > /* > * Memory exhausted. > */ > return 0; > > If I read this correctly, since the AVRX task stack is under > __brkval, malloc won't work if called from a task. > > Maybe I can put a wrapper around malloc to repoint the stack > pointer so that this line is valid: > cp = STACK_POINTER() - __malloc_margin; > > -- > View this message in context: > http://www.nabble.com/malloc-changes-tp22982993p22983132.html > Sent from the AVR - Libc - Dev mailing list archive at Nabble.com. > > > > _______________________________________________ > AVR-libc-dev mailing list > [email protected] > http://lists.nongnu.org/mailman/listinfo/avr-libc-dev > _______________________________________________ AVR-libc-dev mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/avr-libc-dev
