Re: problem with linklist



sunilsomanna@xxxxxxxxx wrote:
template<class T>
void TimerDLList<T>::addFirst(TimerItem<T>* const itemPtr)

This looks lik C++, but this comp.lang.c, not comp.lang.c++.

{
// suppose itemPtr is not pointing to NULL

itemPtr->prev = (TimerItem<T>*) NULL;

head = (TimerItem<T>*)NULL;

if (tail == (TimerItem<T>*)NULL ) // nothing in the link list
{
tail = itemPtr;
itemPtr->next = (TimerItem<T>*) NULL;
}
else
{
itemPtr->next = head;
head->prev = itemPtr;
}

head = itemPtr;
}

there seems to be some problem in head->prev = itemPtr.

When you first set 'head' to NULL then you shouldn't be too
astonished when you can't dereference it later on...

Regards, Jens
--
\ Jens Thoms Toerring ___ jt@xxxxxxxxxxx
\__________________________ http://toerring.de
.