[Tinyos-help] [PoolC] Returning NULL
Philip Levis
pal at cs.stanford.edu
Sat Jul 11 20:52:23 PDT 2009
The simplest answer would be that you're calling put(NULL) at some
point.
Phil
On Jul 11, 2009, at 11:44 PM, Pratibha S wrote:
> 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
>
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help at millennium.berkeley.edu
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
More information about the Tinyos-help
mailing list