gbranden pushed a commit to branch master
in repository groff.

commit ecb40f659f9593a1a3a0b0ecc034d3aa8d14cf56
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Nov 1 18:15:23 2026 -0600

    src/roff/troff/input.cpp: Refactor to simplify.
    
    * src/roff/troff/input.cpp (token::next): Stop wrapping `delete`
      operation with null pointer check.
    
    It is not necessary to make conditional the deletion (or array deletion)
    of a null pointer.  "If the _delete-expression_ calls the implementation
    deallocation function (3.7.3.2), and if the operand of the delete
    expression is not the null pointer constant, the deallocation function
    will deallocate the storage referenced by the pointer thus rendering the
    pointer invalid" (ISO/IEC 14882-1998, ยง5.3.5, paragraph 4).  Or as
    Stroustrup puts it, "Applying _delete_ to zero has no effect." (_The C++
    Programming Language, Special Edition_, p. 128).
---
 ChangeLog                | 5 +++++
 src/roff/troff/input.cpp | 6 ++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b2619a046..027b1b8c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2026-11-01  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/input.cpp (token::next): Refactor to simplify.
+       Stop wrapping `delete` operation with null pointer check.
+
 2026-11-02  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/div.cpp (need_vertical_space_request): Revise
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 32fbeeaa0..cf3d1750b 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -2324,10 +2324,8 @@ void token::make_newline()
 
 void token::next()
 {
-  if (nd != 0 /* nullptr */) {
-    delete nd;
-    nd = 0 /* nullptr */;
-  }
+  delete nd;
+  nd = 0 /* nullptr */;
   units x;
   for (;;) {
     node *n = 0 /* nullptr */;

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to