gbranden pushed a commit to branch master
in repository groff.
commit 6b73e0bafddd1a972b82027fdf7346c5d60bd579
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun May 31 22:48:20 2026 -0500
[grohtml]: Fix code style nit.
* src/devices/grohtml/post-html.cpp
(char_block::~char_block)
(text_glob::~text_glob)
(text_glob::remember_table)
(element_list::~element_list)
(list::sub_move_right)
(replace_negate_str)
(replace_str)
(html_printer::lookahead_for_tables)
(html_printer::draw): Simplify. Don't wrap `delete` operations with
null pointer checks.
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 | 26 ++++++++++++++++++++++++++
src/devices/grohtml/post-html.cpp | 36 ++++++++++++------------------------
2 files changed, 38 insertions(+), 24 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ab214e3fc..90cfbdd0e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2026-05-31 G. Branden Robinson <[email protected]>
+
+ [grohtml]: Fix code style nit.
+
+ * src/devices/grohtml/post-html.cpp
+ (char_block::~char_block)
+ (text_glob::~text_glob)
+ (text_glob::remember_table)
+ (element_list::~element_list)
+ (list::sub_move_right)
+ (replace_negate_str)
+ (replace_str)
+ (html_printer::lookahead_for_tables)
+ (html_printer::draw): Simplify. Don't wrap `delete` operations
+ with null pointer checks.
+
+ 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).
+
2026-05-31 G. Branden Robinson <[email protected]>
* src/devices/grohtml/post-html.cpp: Handle `NDEBUG` builds
diff --git a/src/devices/grohtml/post-html.cpp
b/src/devices/grohtml/post-html.cpp
index 60a8afd33..aa7213a5c 100644
--- a/src/devices/grohtml/post-html.cpp
+++ b/src/devices/grohtml/post-html.cpp
@@ -421,8 +421,7 @@ char_block::char_block(int length)
char_block::~char_block()
{
- if (buffer != 0 /* nullptr */)
- delete[] buffer;
+ delete[] buffer;
}
class char_buffer {
@@ -618,8 +617,7 @@ text_glob::text_glob ()
text_glob::~text_glob ()
{
- if (tab != 0 /* nullptr */)
- delete tab;
+ delete tab;
}
/*
@@ -1025,8 +1023,7 @@ int text_glob::get_tab_args (char *align)
void text_glob::remember_table (html_table *t)
{
- if (tab != 0 /* nullptr */)
- delete tab;
+ delete tab;
tab = t;
}
@@ -1090,8 +1087,7 @@ element_list::element_list (text_glob *in,
element_list::~element_list ()
{
- if (datum != 0 /* nullptr */)
- delete datum;
+ delete datum;
}
class list {
@@ -1243,8 +1239,7 @@ void list::sub_move_right (void)
if (head == tail) {
head = 0;
- if (tail != 0 /* nullptr */)
- delete tail;
+ delete tail;
tail = 0 /* nullptr */;
ptr = 0 /* nullptr */;
@@ -2020,8 +2015,7 @@ void assert_state::close (const char *c)
static const char *replace_negate_str (const char *before, char *after)
{
- if (before != 0 /* nullptr */)
- delete[] before;
+ delete[] before;
assert(after != 0 /* nullptr */);
if (0 /* nullptr */ == after)
@@ -2045,8 +2039,7 @@ static const char *replace_negate_str (const char
*before, char *after)
static const char *replace_str (const char *before, const char *after)
{
- if (before != 0 /* nullptr */)
- delete[] before;
+ delete[] before;
return after;
}
@@ -4042,10 +4035,8 @@ void html_printer::lookahead_for_tables (void)
g = page_contents->glyphs.move_right_get_data();
handle_state_assertion(g);
if (page_contents->glyphs.is_equal_to_head()) {
- if (tbl != 0 /* nullptr */) {
- delete tbl;
- tbl = 0 /* nullptr */;
- }
+ delete tbl;
+ tbl = 0 /* nullptr */;
return;
}
@@ -4204,10 +4195,8 @@ void html_printer::lookahead_for_tables (void)
page_contents->insert_tag(string("*** LAST ***"));
}
}
- if (tbl != 0 /* nullptr */) {
- delete tbl;
- tbl = 0 /* nullptr */;
- }
+ delete tbl;
+ tbl = 0 /* nullptr */;
// and reset the registers
pageoffset = old_pageoffset;
@@ -4690,8 +4679,7 @@ void html_printer::draw(int code, int *p, int np,
break;
case 'F':
// fill with color env->fill
- if (background != 0 /* nullptr */)
- delete background;
+ delete background;
background = new color;
*background = *env->fill;
break;
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit