CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

free function hangs up PIC

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
joseosanchez



Joined: 26 Jul 2004
Posts: 2

View user's profile Send private message

free function hangs up PIC
PostPosted: Mon Jul 26, 2004 3:09 pm     Reply with quote

Hi I implemented a linked list on my PIC which contains the sensors connected to the CAN bus, however, when I unplug a sensor and I try to remove the sensor from the list, sometimes it hangs up when it calls the free function. I debbuged the code using ICD and everythings seems to be ok until the free function is called where it stays forever.

My remove functios is as follows:

int removeSensor(int16 id)
{
struct sensors *curr=NULL, *prev=NULL;
if(selectsensor(id)==NOTFOUND)
return(NOTFOUND);
if(first->id==id)
{
curr=first;
first=curr->next;

}
else
{
prev=first;
curr=first->next;
while(!(curr->id==id))
{
prev=curr;
curr=curr->next;
}
prev->next=curr->next;
}
free(curr);
anz-=1;

return(OK);

}

I hope someone has an idea how to solve this problem.

thanks

Jose
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Mon Jul 26, 2004 5:08 pm     Reply with quote

The code for free() is in the STDLIBM.H file. Debug your code, and instead of jumping over the free() function step through it. This way you shuold be able to figure out what exactly is causing the problem.
joseosanchez



Joined: 26 Jul 2004
Posts: 2

View user's profile Send private message

free function hangs up PIC
PostPosted: Tue Jul 27, 2004 8:31 am     Reply with quote

I was debbuging the code and I noticed that it hangs up in the function traverse() located in stdlibm.h and specially in a function that traverse calls which is remove_node located in memmgmt.c. For the moment being I removed the free function and the PIC does not hangs but of course I am leaving spaces of memory without allocation which is not right, but I have no idea what to do to solve this problem.

any ideas.

Jose
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group