[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ns] bug and patch for queue.h



On Wed, 15 Aug 2001, Neundorf Alexander wrote:

> an obvious bug with a simple fix (found in 2.1b7 and b8):
> 
> queue.h:
> 
> class PacketQueue
> {
> ...
>    Packet* getNext()
>    {
>       Packet *tmp=iter;
> -     iter=iter->next_;
> +    if (iter!=0) iter=iter->next_;

if (NULL!=iter) iter=iter->next_;

strikes me as the least ambiguous way of phrasing that, although
convention in queue.h would suggest an earlier
	if (!iter) return 0;

instead. good catch.

L.

is a witness to ongoing arguments about what NULL actually IS.

>    return tmp;
> };
> 
> now I can use loops like
> resetIterator();
> for (Packet* p=getNext(); p!=0; p=getNext())
> { ... };
> 
> Bye
> Alex

<[email protected]>PGP<http://www.ee.surrey.ac.uk/Personal/L.Wood/>