be-more-careful-about-references-when-adding-and-deleting-callbacks-20011001

perhaps too careful. to fix potential crash in TDel and TAdd

====================
This delta was composed from multiple commits as part of the CVS->Git migration.
The checkin message with each commit was inconsistent.
The following are the additional commit messages.
====================

remove extra ) which snuck in
This commit is contained in:
Derrick Brashear 2001-10-01 18:51:41 +00:00
parent 7afd82623d
commit 8a3eb1f06d

View File

@ -358,7 +358,12 @@ static TAdd(cb, thead)
cb->tprev = thp->tprev;
cb->tnext = *thead;
thp->tprev = (itocb(thp->tprev)->tnext = cbtoi(cb));
if (thp) {
if (thp->tprev)
thp->tprev = (itocb(thp->tprev)->tnext = cbtoi(cb));
else
thp->tprev = cbtoi(cb);
}
}
cb->thead = ttoi(thead);
@ -374,8 +379,10 @@ static TDel(cb)
if (*thead == cbtoi(cb))
*thead = (*thead == cb->tnext? 0: cb->tnext);
itocb(cb->tprev)->tnext = cb->tnext;
itocb(cb->tnext)->tprev = cb->tprev;
if (itocb(cb->tprev))
itocb(cb->tprev)->tnext = cb->tnext;
if (itocb(cb->tnext))
itocb(cb->tnext)->tprev = cb->tprev;
} /*TDel*/