[Tinyos-help] [PoolC] Returning NULL
Pratibha S
psundars at gmail.com
Sun Jul 12 06:23:29 PDT 2009
It is because of the emptyIndex. I was initializing objects with sizes 140,
150 and (index + free) was exceeding 255. for smaller sizes, it is not
causing this error. When i change the size of emptyIndex to uint16_t with
the same 140,150 sizes, it is working fine now. Thank you all :)
On Sun, Jul 12, 2009 at 11:52 AM, Philip Levis <pal at cs.stanford.edu> wrote:
> 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
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.millennium.berkeley.edu/pipermail/tinyos-help/attachments/20090712/3573f3cd/attachment.htm
More information about the Tinyos-help
mailing list