Hi Gregory
Not really. C++ guarantees that operator delete checks its argument for
null-ness. If the argument is 0, the delete expression has no effect. In
other words, deleting a null pointer is a safe (yet useless) operation.
There is no need to check the pointer for null-ness before passing it to
delete.
Jacek
Gregory J. Sharp wrote:
> Folks,
>
> The following change might also be a suitable form of defensive
> programming:
>
> in XrdXr/XrdXrClientWorker.cc in the destructor, it would be
> comforting to change:
>
> delete xrootd; xrootd = 0;
> delete errInfo; errInfo = 0;
> to
> if (xrootd) { delete xrootd; xrootd = 0; }
> if (errInfo) { delete errInfo; errInfo = 0; }
>
> and, totally free of charge, the trailing ; on the following line can
> go away.
>
> --
> Gregory J. Sharp email: [log in to unmask]
> Wilson Synchrotron Laboratory url:
> http://www.lepp.cornell.edu/~gregor
> Dryden Rd ph: +1 607 255 4882
> Ithaca, NY 14853 fax: +1 607 255 8062
>
|