[Tinyos-help] [PoolC] Returning NULL
Pratibha S
psundars at gmail.com
Thu Jul 9 17:23:50 PDT 2009
Hi,
PoolC get() is returning NULL even though not Pool.empty() and
Pool.size()>0.
I allocate a pointer-to-struct say 'position_t' having three pointers v[3],
typedef position * position_t;
interface Pool<position>;
void New_position()
{ position_t pos;
if(! call Pool.empty()){
atomic{
pos = call edgePool.get();
}}
else
{
dbg_clear("usr","Out of memory - %d\n",call Pool.size());
exit(0);
}
if(pos == NULL) // Becomes TRUE and printing non_zero size
dbg_clear("usr", "Failed allocation -%d\n", call Pool.size());
pos->v[0] = NULL; // SEGMENTATION FAULT OCCURS HERE
pos->v[1] = NULL;
pos->v[2] = NULL;
return pos;
}
this code doesn't cause segmentation fault every time, it is
called. variables in Pool will be constantly allocated and freed. after some
put()s and get()s, this is causing error. Can anyone tell me why?
Regards,
Pratibha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.millennium.berkeley.edu/pipermail/tinyos-help/attachments/20090710/c479d587/attachment.htm
More information about the Tinyos-help
mailing list