struct TYPE
{
int id;
struct TYPE *next;
};
static struct TYPE *head;
int add_item(struct TYPE *item)
{
int ret = -EEXIST;
struct TYPE **p;
p = &head;
while(*p != NULL)
{
if((*p)->id == item->id)
{
break;
}
p = &(*p)->next;
}
if(*p == NULL)
{
*p = item;
ret = 0;
}
return ret;
}
void del_item(struct TYPE *item)
{
struct TYPE **p;
p = &head;
while(*p != NULL)
{
if((*p)->id == item->id)
{
*p = item->next;
break;
}
p = &(*p)->next;
}
}
阅读(1067) | 评论(0) | 转发(0) |