[Tinyos-help] Re: Dynamic Memory Allocation

2008-01-29 Thread AIGroup
I believed... I'm using TinyOS 2.0. I tried to compile and use these statements in my code: int *x; x=(int *)(malloc(sizeof(int))); *x=4; dbg(BlinkC, Timer 0 fired @ %s.\nContenuto di x = %d\n, sim_time_string(), *x); and all works well! So...why using malloc() is dangerous? (as I

Re: [Tinyos-help] Re: Dynamic Memory Allocation

2008-01-29 Thread Urs Hunkeler
Hi, Malloc might work in a simulation environment, but it does not work on the physical motes. So if you want to program real hardware you'll have to find a way to avoid malloc. Cheers, Urs AIGroup wrote: I believed... I'm using TinyOS 2.0. I tried to compile and use these statements in

Re: [Tinyos-help] Re: Dynamic Memory Allocation

2008-01-29 Thread Philip Levis
On Jan 29, 2008, at 2:49 AM, AIGroup wrote: I believed... I'm using TinyOS 2.0. I tried to compile and use these statements in my code: int *x; x=(int *)(malloc(sizeof(int))); *x=4; dbg(BlinkC, Timer 0 fired @ %s.\nContenuto di x = %d\n, sim_time_string(), *x); and all

Re: [Tinyos-help] Re: Dynamic Memory Allocation

2008-01-29 Thread Kevin Klues
Malloc actually should work on the mote hardware if you want to try it. Whiel its use is discouraged, there is technically nothing preventing you from using it. Kevin On Jan 29, 2008 3:52 AM, Urs Hunkeler [EMAIL PROTECTED] wrote: Hi, Malloc might work in a simulation environment, but it does

Re: [Tinyos-help] Re: Dynamic Memory Allocation

2008-01-29 Thread Dimas Abreu Dutra
Perhaps you should use the PoolC component which provides similar functionalities but is safer. It works with pre-allocation. ~Dimas~ 2008/1/29, Philip Levis [EMAIL PROTECTED]: On Jan 29, 2008, at 2:49 AM, AIGroup wrote: I believed... I'm using TinyOS 2.0. I tried to compile and use

Re: [Tinyos-help] Re: Dynamic Memory Allocation

2008-01-29 Thread Omprakash Gnawali
On Jan 29, 2008 11:36 AM, Philip Levis [EMAIL PROTECTED] wrote: On Jan 29, 2008, at 2:49 AM, AIGroup wrote: I believed... I'm using TinyOS 2.0. I tried to compile and use these statements in my code: int *x; x=(int *)(malloc(sizeof(int))); *x=4; dbg(BlinkC, Timer 0