Hi everyone.

I have been reading some old mails that had been posted a couple months ago in this list about memory in the motes and nesc. From what i understood the use of malloc to provide dynamic memory allocation isn't advised. There was some talk about using TinyAlloc, but i couldn't find that in T2 and in my case i have been using malloc without any problems, but reading those mails made me want to change my code to do the right away, so i don't have unexpected long term problems.

If i wanted to pass arrays of data between 2 components , what is the best way to this without having memory problems/or any kind of problems.

The way i am doing:
command uint8_t* Component1.getSomething(uint8_t size) {
  uint8_t *array=malloc(size*sizeof(*array));
  /*  Fill array with something */
  return array;
}

In Component2:
task void someName() {
  uint8_t* pointer;
  pointer = call Component1.getSomething(size);
  /* Do something with data */
}

Thanks,
Ricardo

_________________________________________________________________
MSN Messenger: converse com os seus amigos online. http://messenger.msn.com.br

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

Reply via email to