Re: problem with linklist
- From: jt@xxxxxxxxxxx (Jens Thoms Toerring)
- Date: 5 Jul 2007 15:19:05 GMT
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
.
- References:
- problem with linklist
- From: sunilsomanna
- problem with linklist
- Prev by Date: Re: problem with linklist
- Next by Date: Re: Does *&s1 refer to the first member of structure variable s1
- Previous by thread: Re: problem with linklist
- Next by thread: Re: problem with linklist
- Index(es):