[Tinyos-help] [PoolC] Returning NULL
Pratibha S
psundars at gmail.com
Sat Jul 11 20:44:56 PDT 2009
sorry, that was a typo.. im getting and putting in the same pool.
On Sat, Jul 11, 2009 at 12:57 AM, Omprakash Gnawali <gnawali at usc.edu> wrote:
> On Thu, Jul 9, 2009 at 5:23 PM, Pratibha S<psundars at gmail.com> wrote:
> > 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?
>
> You are checking Pool and getting from edgePool?
>
> - om_p
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.millennium.berkeley.edu/pipermail/tinyos-help/attachments/20090712/81e44fb6/attachment.htm
More information about the Tinyos-help
mailing list