I don't know, offhand, how to get an available memory reading
at runtime...hopefully someone else is smarter than me and
will share...

You can see how much RAM you've used at the end of the compile
output and use that as a guide to how large your array can be.
In general you'll have to invent an alloc-from-large-buffer
scheme of some kind if you want to get it at runtime. In that
case you would declare your pointer as you did and then set
it to the result of your alloc-thing before using it.

MS

Islam Hegazy wrote:
The problem that I am facing is that I don't what is the value of SomeSmallSize... I can go the other way around by specifying a large value but I am afraid that I may overflow the memory so is there a way to compute the available memory?

Islam Hegazy

----- Original Message ----- From: "Michael Schippling" <[EMAIL PROTECTED]>
To: "Islam Hegazy" <[EMAIL PROTECTED]>
Cc: <[email protected]>
Sent: Thursday, September 13, 2007 2:25 PM
Subject: Re: [Tinyos-help] initializing pointers


You have made a pointer, but it doesn't point to anything...
or more preciesely it is probably initialized to 0, so it
points to the bottom of memory. Since there isn't any mem
management (to speak of) the easiest thing is to create
your array directly:

uint16_t dataArr[SOMEsmallSIZE];

Otherwise the usage is the same as you show.

For all kinds of interesting facts about C, see:
http://en.wikibooks.org/wiki/C_Programming

MS

Islam Hegazy wrote:
Hi all
I want to use a dynamic array in my sensor application. Is there a way to iniailize the array before using it like the keyword new in C++?
 I defined the array as : uint16_t *dataArr
when I access it as : dataArr[numData++] = value
it gives a runtime error.
 I am working with mica2 and TinyOS1.
 Regards
Islam Hegazy


------------------------------------------------------------------------

_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

--
Platform: WinXP/Cygwin
TinyOS version: 1.x, Boomerang
Programmer: MIB510
Device(s): Mica2, MicaZ, Tmote
Sensor board: homebrew


--
Platform: WinXP/Cygwin
TinyOS version: 1.x, Boomerang
Programmer: MIB510
Device(s): Mica2, MicaZ, Tmote
Sensor board: homebrew

_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to