If "serial_source" has been typedefed to be a pointer,
which is what the subsequent usage tends to indicate,
then this _should_ allocate and init a block of whatever
rather than just a pointer. If that is the case then it
seems to be a poor naming choice. You'll have to chase
the dragon further up the tree to see what it really is...
MS
Daniel Widyanto wrote:
Hi all,
I'm currently debugging strange error in serial forwarder (c version,
TinyOS 2.0.1), and I found this :
//////////////////
serialsource.c:273:
serial_source src = malloc(sizeof *src);
if (src)
{
memset(src, 0, sizeof *src);
src->fd = fd;
src->non_blocking = non_blocking;
src->message = message;
src->send.seqno = 37;
return src;
}
///////////////////
I think malloc(sizeof *src) will return pointer to 4-bytes allocated heap,
instead of pointer to sizeof(struct serial_source). So, src->non_blocking,
src->message, and src->send.seqno will point to memory that's not
belonging to this program.
Please correct me if I'm wrong.
Regards,
-daniel
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help